mirror of https://github.com/grpc/grpc.git
[tests] Convert core e2e tests to gtest (#32603)
Notes: - `+trace` fixtures haven't run since 2016, so they're disabled for now (pull/32792/head7ad2d0b463 (diff-780fce7267c34170c1d0ea15cc9f65a7f4b79fefe955d185c44e8b3251cf9e38R76)
) - all current fixtures define `FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER` and hence `authority_not_supported` has not been run in years - deleted - bad_hostname similarly hasn't been triggered in a long while, so deleted - load_reporting_hook has never been enabled, so deleted (f23fb4cf31/test/core/end2end/generate_tests.bzl (L145-L148)
) - filter_latency & filter_status_code rely on global variables and so don't convert particularly cleanly - and their value seems marginal, so deleted --------- Co-authored-by: ctiller <ctiller@users.noreply.github.com>
parent
d551a512c8
commit
724441d85b
172 changed files with 10111 additions and 26124 deletions
File diff suppressed because it is too large
Load Diff
@ -1,330 +0,0 @@ |
||||
/* |
||||
* |
||||
* Copyright 2015 gRPC authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
* |
||||
*/ |
||||
|
||||
/* |
||||
* This test file is derived from fixture h2_ssl.c in core end2end test |
||||
* (test/core/end2end/fixture/h2_ssl.c). The structure of the fixture is |
||||
* preserved as much as possible |
||||
* |
||||
* This fixture creates a server full stack using chttp2 and a client |
||||
* full stack using Cronet. End-to-end tests are run against this |
||||
* configuration |
||||
* |
||||
*/ |
||||
|
||||
#import <XCTest/XCTest.h> |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
|
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/support/alloc.h> |
||||
#include <grpc/support/log.h> |
||||
#include "src/core/lib/gprpp/crash.h" |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "src/core/lib/gpr/string.h" |
||||
#include "src/core/lib/gpr/tmpfile.h" |
||||
#include "src/core/lib/gprpp/host_port.h" |
||||
#include "src/core/lib/security/credentials/credentials.h" |
||||
|
||||
#include "test/core/end2end/data/ssl_test_data.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
#import <Cronet/Cronet.h> |
||||
#include <grpc/grpc_cronet.h> |
||||
|
||||
#import "../ConfigureCronet.h" |
||||
|
||||
static void process_auth_failure(void *state, grpc_auth_context *ctx, const grpc_metadata *md, |
||||
size_t md_count, grpc_process_auth_metadata_done_cb cb, |
||||
void *user_data) { |
||||
GPR_ASSERT(state == nullptr); |
||||
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); |
||||
} |
||||
|
||||
class CronetFixture final : public SecureFixture { |
||||
private: |
||||
grpc_channel_credentials *MakeClientCreds(const grpc_core::ChannelArgs &args) override { |
||||
grpc_core::Crash("unreachable"); |
||||
} |
||||
grpc_server_credentials *MakeServerCreds(const grpc_core::ChannelArgs &args) override { |
||||
grpc_ssl_pem_key_cert_pair pem_cert_key_pair = {test_server1_key, test_server1_cert}; |
||||
grpc_server_credentials *ssl_creds = |
||||
grpc_ssl_server_credentials_create(nullptr, &pem_cert_key_pair, 1, 0, nullptr); |
||||
if (args.Contains(FAIL_AUTH_CHECK_SERVER_ARG_NAME)) { |
||||
grpc_auth_metadata_processor processor = {process_auth_failure, nullptr, nullptr}; |
||||
grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor); |
||||
} |
||||
return ssl_creds; |
||||
} |
||||
grpc_channel *MakeClient(const grpc_core::ChannelArgs &args) override { |
||||
stream_engine *cronetEngine = [Cronet getGlobalEngine]; |
||||
return grpc_cronet_secure_channel_create(cronetEngine, localaddr().c_str(), args.ToC().get(), |
||||
nullptr); |
||||
} |
||||
}; |
||||
|
||||
/* All test configurations */ |
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, nullptr, |
||||
[](const grpc_core::ChannelArgs & /*client_args*/, |
||||
const grpc_core::ChannelArgs & /*server_args*/) { |
||||
return std::make_unique<CronetFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
static char *roots_filename; |
||||
|
||||
@interface CoreCronetEnd2EndTests : XCTestCase |
||||
|
||||
@end |
||||
|
||||
@implementation CoreCronetEnd2EndTests |
||||
|
||||
// The setUp() function is run before the test cases run and only run once |
||||
+ (void)setUp { |
||||
[super setUp]; |
||||
|
||||
FILE *roots_file; |
||||
size_t roots_size = strlen(test_root_cert); |
||||
|
||||
char *argv[] = {(char *)"CoreCronetEnd2EndTests"}; |
||||
int argc = 1; |
||||
grpc_test_init(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
|
||||
/* Set the SSL roots env var. */ |
||||
roots_file = gpr_tmpfile("chttp2_simple_ssl_fullstack_test", &roots_filename); |
||||
GPR_ASSERT(roots_filename != nullptr); |
||||
GPR_ASSERT(roots_file != nullptr); |
||||
GPR_ASSERT(fwrite(test_root_cert, 1, roots_size, roots_file) == roots_size); |
||||
fclose(roots_file); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = roots_filename; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
grpc_init(); |
||||
|
||||
configureCronet(/*enable_netlog=*/false); |
||||
} |
||||
|
||||
// The tearDown() function is run after all test cases finish running |
||||
+ (void)tearDown { |
||||
grpc_shutdown(); |
||||
|
||||
/* Cleanup. */ |
||||
remove(roots_filename); |
||||
gpr_free(roots_filename); |
||||
|
||||
[super tearDown]; |
||||
} |
||||
|
||||
- (void)testIndividualCase:(char *)test_case { |
||||
char *argv[] = {(char *)"h2_ssl", test_case}; |
||||
for (int i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(2, argv, configs[i]); |
||||
} |
||||
} |
||||
|
||||
// TODO(mxyan): Use NSStringFromSelector(_cmd) to acquire test name from the |
||||
// test case method name, so that bodies of test cases can stay identical |
||||
- (void)testAuthorityNotSupported { |
||||
[self testIndividualCase:(char *)"authority_not_supported"]; |
||||
} |
||||
|
||||
- (void)testBadHostname { |
||||
[self testIndividualCase:(char *)"bad_hostname"]; |
||||
} |
||||
|
||||
- (void)testBinaryMetadata { |
||||
[self testIndividualCase:(char *)"binary_metadata"]; |
||||
} |
||||
|
||||
- (void)testCallCreds { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"call_creds"]; |
||||
} |
||||
|
||||
- (void)testCancelAfterAccept { |
||||
[self testIndividualCase:(char *)"cancel_after_accept"]; |
||||
} |
||||
|
||||
- (void)testCancelAfterClientDone { |
||||
[self testIndividualCase:(char *)"cancel_after_client_done"]; |
||||
} |
||||
|
||||
- (void)testCancelAfterInvoke { |
||||
[self testIndividualCase:(char *)"cancel_after_invoke"]; |
||||
} |
||||
|
||||
- (void)testCancelAfterRoundTrip { |
||||
[self testIndividualCase:(char *)"cancel_after_round_trip"]; |
||||
} |
||||
|
||||
- (void)testCancelBeforeInvoke { |
||||
[self testIndividualCase:(char *)"cancel_before_invoke"]; |
||||
} |
||||
|
||||
- (void)testCancelInAVacuum { |
||||
[self testIndividualCase:(char *)"cancel_in_a_vacuum"]; |
||||
} |
||||
|
||||
- (void)testCancelWithStatus { |
||||
[self testIndividualCase:(char *)"cancel_with_status"]; |
||||
} |
||||
|
||||
- (void)testCompressedPayload { |
||||
[self testIndividualCase:(char *)"compressed_payload"]; |
||||
} |
||||
|
||||
- (void)testConnectivity { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"connectivity"]; |
||||
} |
||||
|
||||
- (void)testDefaultHost { |
||||
[self testIndividualCase:(char *)"default_host"]; |
||||
} |
||||
|
||||
- (void)testDisappearingServer { |
||||
[self testIndividualCase:(char *)"disappearing_server"]; |
||||
} |
||||
|
||||
- (void)testEmptyBatch { |
||||
[self testIndividualCase:(char *)"empty_batch"]; |
||||
} |
||||
|
||||
- (void)testFilterCausesClose { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"filter_causes_close"]; |
||||
} |
||||
|
||||
- (void)testGracefulServerShutdown { |
||||
[self testIndividualCase:(char *)"graceful_server_shutdown"]; |
||||
} |
||||
|
||||
- (void)testHighInitialSeqno { |
||||
[self testIndividualCase:(char *)"high_initial_seqno"]; |
||||
} |
||||
|
||||
- (void)testHpackSize { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"hpack_size"]; |
||||
} |
||||
|
||||
- (void)testIdempotentRequest { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"idempotent_request"]; |
||||
} |
||||
|
||||
- (void)testInvokeLargeRequest { |
||||
// NOT SUPPORTED (frame size) |
||||
// [self testIndividualCase:(char *)"invoke_large_request"]; |
||||
} |
||||
|
||||
- (void)testLargeMetadata { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"large_metadata"]; |
||||
} |
||||
|
||||
- (void)testMaxConcurrentStreams { |
||||
[self testIndividualCase:(char *)"max_concurrent_streams"]; |
||||
} |
||||
|
||||
- (void)testMaxMessageLength { |
||||
// NOT SUPPORTED (close_error) |
||||
// [self testIndividualCase:(char *)"max_message_length"]; |
||||
} |
||||
|
||||
- (void)testNegativeDeadline { |
||||
[self testIndividualCase:(char *)"negative_deadline"]; |
||||
} |
||||
|
||||
- (void)testNoOp { |
||||
[self testIndividualCase:(char *)"no_op"]; |
||||
} |
||||
|
||||
- (void)testPayload { |
||||
[self testIndividualCase:(char *)"payload"]; |
||||
} |
||||
|
||||
- (void)testPing { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"ping"]; |
||||
} |
||||
|
||||
- (void)testPingPongStreaming { |
||||
[self testIndividualCase:(char *)"ping_pong_streaming"]; |
||||
} |
||||
|
||||
- (void)testRegisteredCall { |
||||
[self testIndividualCase:(char *)"registered_call"]; |
||||
} |
||||
|
||||
- (void)testRequestWithFlags { |
||||
// NOT SUPPORTED |
||||
// [self testIndividualCase:(char *)"request_with_flags"]; |
||||
} |
||||
|
||||
- (void)testRequestWithPayload { |
||||
[self testIndividualCase:(char *)"request_with_payload"]; |
||||
} |
||||
|
||||
- (void)testServerFinishesRequest { |
||||
[self testIndividualCase:(char *)"server_finishes_request"]; |
||||
} |
||||
|
||||
- (void)testServerStreaming { |
||||
[self testIndividualCase:(char *)"server_streaming"]; |
||||
} |
||||
|
||||
- (void)testShutdownFinishesCalls { |
||||
[self testIndividualCase:(char *)"shutdown_finishes_calls"]; |
||||
} |
||||
|
||||
- (void)testShutdownFinishesTags { |
||||
[self testIndividualCase:(char *)"shutdown_finishes_tags"]; |
||||
} |
||||
|
||||
- (void)testSimpleDelayedRequest { |
||||
[self testIndividualCase:(char *)"simple_delayed_request"]; |
||||
} |
||||
|
||||
- (void)testSimpleMetadata { |
||||
[self testIndividualCase:(char *)"simple_metadata"]; |
||||
} |
||||
|
||||
- (void)testSimpleRequest { |
||||
[self testIndividualCase:(char *)"simple_request"]; |
||||
} |
||||
|
||||
- (void)testStreamingErrorResponse { |
||||
[self testIndividualCase:(char *)"streaming_error_response"]; |
||||
} |
||||
|
||||
- (void)testTrailingMetadata { |
||||
[self testIndividualCase:(char *)"trailing_metadata"]; |
||||
} |
||||
|
||||
@end |
@ -1,72 +0,0 @@ |
||||
<%def name="end2end_selector(tests)"> |
||||
// |
||||
// |
||||
// Copyright 2015 gRPC authors. |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
// |
||||
// |
||||
|
||||
<% tests = sorted(tests) %>\ |
||||
// This file is auto-generated |
||||
|
||||
#include "test/core/end2end/end2end_tests.h" |
||||
|
||||
#include <stdbool.h> |
||||
#include <string.h> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
|
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/gprpp/crash.h" |
||||
|
||||
static bool g_pre_init_called = false; |
||||
|
||||
% for test in tests: |
||||
extern void ${test}(const CoreTestConfiguration& config); |
||||
extern void ${test}_pre_init(void); |
||||
% endfor |
||||
|
||||
void grpc_end2end_tests_pre_init(void) { |
||||
GPR_ASSERT(!g_pre_init_called); |
||||
g_pre_init_called = true; |
||||
% for test in tests: |
||||
${test}_pre_init(); |
||||
% endfor |
||||
} |
||||
|
||||
// NOLINTNEXTLINE(readability-function-size) |
||||
void grpc_end2end_tests(int argc, char **argv, |
||||
const CoreTestConfiguration& config) { |
||||
int i; |
||||
|
||||
GPR_ASSERT(g_pre_init_called); |
||||
|
||||
if (argc <= 1) { |
||||
% for test in tests: |
||||
${test}(config); |
||||
% endfor |
||||
return; |
||||
} |
||||
|
||||
for (i = 1; i < argc; i++) { |
||||
% for test in tests: |
||||
if (0 == strcmp("${test}", argv[i])) { |
||||
${test}(config); |
||||
continue; |
||||
} |
||||
% endfor |
||||
grpc_core::Crash(absl::StrFormat( "not a test: '%s'", argv[i])); |
||||
} |
||||
}</%def> |
@ -1,4 +0,0 @@ |
||||
%YAML 1.2 |
||||
--- | |
||||
<%namespace file="end2end_defs.include" import="*"/>\ |
||||
${end2end_selector(core_end2end_tests.keys())} |
@ -1,7 +0,0 @@ |
||||
Each fixture (under fixtures/) is paired with each test (under tests/) and |
||||
forms a complete end-to-end test. |
||||
|
||||
To add a new test or fixture: |
||||
- add the code to the relevant directory |
||||
- update generate_tests.bzl to reflect the change |
||||
- regenerate projects |
File diff suppressed because it is too large
Load Diff
@ -1,49 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <grpc/slice.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "test/core/end2end/end2end_tests.h" |
||||
|
||||
const char* get_host_override_string(const char* str, |
||||
const CoreTestConfiguration& config) { |
||||
if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { |
||||
return str; |
||||
} else { |
||||
return nullptr; |
||||
} |
||||
} |
||||
|
||||
const grpc_slice* get_host_override_slice(const char* str, |
||||
const CoreTestConfiguration& config) { |
||||
const char* r = get_host_override_string(str, config); |
||||
if (r != nullptr) { |
||||
static grpc_slice ret; |
||||
ret = grpc_slice_from_static_string(r); |
||||
return &ret; |
||||
} |
||||
return nullptr; |
||||
} |
||||
|
||||
void validate_host_override_string(const char* pattern, grpc_slice str, |
||||
const CoreTestConfiguration& config) { |
||||
if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { |
||||
GPR_ASSERT(0 == grpc_slice_str_cmp(str, pattern)); |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
@ -1,87 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/gprpp/host_port.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
class CensusFixture : public CoreTestFixture { |
||||
private: |
||||
grpc_server* MakeServer(const grpc_core::ChannelArgs& args) override { |
||||
grpc_server_credentials* server_creds = |
||||
grpc_insecure_server_credentials_create(); |
||||
auto* server = grpc_server_create( |
||||
args.Set(GRPC_ARG_ENABLE_CENSUS, true).ToC().get(), nullptr); |
||||
grpc_server_register_completion_queue(server, cq(), nullptr); |
||||
GPR_ASSERT( |
||||
grpc_server_add_http2_port(server, localaddr_.c_str(), server_creds)); |
||||
grpc_server_credentials_release(server_creds); |
||||
grpc_server_start(server); |
||||
return server; |
||||
} |
||||
grpc_channel* MakeClient(const grpc_core::ChannelArgs& args) override { |
||||
auto* creds = grpc_insecure_credentials_create(); |
||||
auto* client = |
||||
grpc_channel_create(localaddr_.c_str(), creds, |
||||
args.Set(GRPC_ARG_ENABLE_CENSUS, true).ToC().get()); |
||||
grpc_channel_credentials_release(creds); |
||||
return client; |
||||
} |
||||
const std::string localaddr_ = |
||||
grpc_core::JoinHostPort("localhost", grpc_pick_unused_port_or_die()); |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack+census", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<CensusFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,96 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include <grpc/compression.h> |
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/gprpp/host_port.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
class CompressionFixture : public CoreTestFixture { |
||||
private: |
||||
grpc_server* MakeServer(const grpc_core::ChannelArgs& args) override { |
||||
auto* server = grpc_server_create( |
||||
args.SetIfUnset(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, |
||||
GRPC_COMPRESS_GZIP) |
||||
.ToC() |
||||
.get(), |
||||
nullptr); |
||||
grpc_server_register_completion_queue(server, cq(), nullptr); |
||||
grpc_server_credentials* server_creds = |
||||
grpc_insecure_server_credentials_create(); |
||||
GPR_ASSERT( |
||||
grpc_server_add_http2_port(server, localaddr_.c_str(), server_creds)); |
||||
grpc_server_credentials_release(server_creds); |
||||
grpc_server_start(server); |
||||
return server; |
||||
} |
||||
grpc_channel* MakeClient(const grpc_core::ChannelArgs& args) override { |
||||
grpc_channel_credentials* creds = grpc_insecure_credentials_create(); |
||||
auto* client = grpc_channel_create( |
||||
localaddr_.c_str(), creds, |
||||
args.SetIfUnset(GRPC_COMPRESSION_CHANNEL_DEFAULT_ALGORITHM, |
||||
GRPC_COMPRESS_GZIP) |
||||
.ToC() |
||||
.get()); |
||||
grpc_channel_credentials_release(creds); |
||||
return client; |
||||
} |
||||
|
||||
std::string localaddr_ = |
||||
grpc_core::JoinHostPort("localhost", grpc_pick_unused_port_or_die()); |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_compression", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<CompressionFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,89 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/security/credentials/fake/fake_credentials.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, |
||||
const grpc_metadata* /*md*/, |
||||
size_t /*md_count*/, |
||||
grpc_process_auth_metadata_done_cb cb, |
||||
void* user_data) { |
||||
GPR_ASSERT(state == nullptr); |
||||
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); |
||||
} |
||||
|
||||
class FakesecFixture : public SecureFixture { |
||||
private: |
||||
grpc_channel_credentials* MakeClientCreds( |
||||
const grpc_core::ChannelArgs&) override { |
||||
return grpc_fake_transport_security_credentials_create(); |
||||
} |
||||
grpc_server_credentials* MakeServerCreds( |
||||
const grpc_core::ChannelArgs& args) override { |
||||
grpc_server_credentials* fake_ts_creds = |
||||
grpc_fake_transport_security_server_credentials_create(); |
||||
if (args.Contains(FAIL_AUTH_CHECK_SERVER_ARG_NAME)) { |
||||
grpc_auth_metadata_processor processor = {process_auth_failure, nullptr, |
||||
nullptr}; |
||||
grpc_server_credentials_set_auth_metadata_processor(fake_ts_creds, |
||||
processor); |
||||
} |
||||
return fake_ts_creds; |
||||
} |
||||
}; |
||||
|
||||
// All test configurations
|
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fake_secure_fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS_LEVEL_INSECURE, |
||||
nullptr, [](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<FakesecFixture>(); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,111 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include "absl/status/status.h" |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/iomgr/error.h" |
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
// This test won't work except with posix sockets enabled
|
||||
#ifdef GRPC_POSIX_SOCKET |
||||
|
||||
#include <fcntl.h> |
||||
#include <string.h> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_posix.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/iomgr/exec_ctx.h" |
||||
#include "src/core/lib/iomgr/socket_utils_posix.h" |
||||
#include "src/core/lib/iomgr/unix_sockets_posix.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static void create_sockets(int sv[2]) { |
||||
int flags; |
||||
grpc_create_socketpair_if_unix(sv); |
||||
flags = fcntl(sv[0], F_GETFL, 0); |
||||
GPR_ASSERT(fcntl(sv[0], F_SETFL, flags | O_NONBLOCK) == 0); |
||||
flags = fcntl(sv[1], F_GETFL, 0); |
||||
GPR_ASSERT(fcntl(sv[1], F_SETFL, flags | O_NONBLOCK) == 0); |
||||
GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[0]) == absl::OkStatus()); |
||||
GPR_ASSERT(grpc_set_socket_no_sigpipe_if_possible(sv[1]) == absl::OkStatus()); |
||||
} |
||||
|
||||
class FdFixture : public CoreTestFixture { |
||||
public: |
||||
FdFixture() { create_sockets(fd_pair_); } |
||||
|
||||
private: |
||||
grpc_server* MakeServer(const grpc_core::ChannelArgs& args) override { |
||||
grpc_core::ExecCtx exec_ctx; |
||||
auto* server = grpc_server_create(args.ToC().get(), nullptr); |
||||
grpc_server_register_completion_queue(server, cq(), nullptr); |
||||
grpc_server_start(server); |
||||
grpc_server_credentials* creds = grpc_insecure_server_credentials_create(); |
||||
grpc_server_add_channel_from_fd(server, fd_pair_[1], creds); |
||||
grpc_server_credentials_release(creds); |
||||
return server; |
||||
} |
||||
grpc_channel* MakeClient(const grpc_core::ChannelArgs& args) override { |
||||
grpc_core::ExecCtx exec_ctx; |
||||
grpc_channel_credentials* creds = grpc_insecure_credentials_create(); |
||||
auto* client = grpc_channel_create_from_fd("fixture_client", fd_pair_[0], |
||||
creds, args.ToC().get()); |
||||
grpc_channel_credentials_release(creds); |
||||
return client; |
||||
} |
||||
|
||||
int fd_pair_[2]; |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fd", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<FdFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
#else // GRPC_POSIX_SOCKET
|
||||
|
||||
int main(int /* argc */, char** /* argv */) { return 1; } |
||||
|
||||
#endif // GRPC_POSIX_SOCKET
|
@ -1,72 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/iomgr/port.h" |
||||
|
||||
// This test requires posix wakeup fds
|
||||
#ifdef GRPC_POSIX_WAKEUP_FD |
||||
|
||||
#include <string.h> |
||||
|
||||
#include "src/core/lib/iomgr/wakeup_fd_posix.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
return std::make_unique<InsecureFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc_allow_specialized_wakeup_fd = 0; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
#else // GRPC_POSIX_WAKEUP_FD
|
||||
|
||||
int main(int argc, char** argv) { return 1; } |
||||
|
||||
#endif // GRPC_POSIX_WAKEUP_FD
|
@ -1,95 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <grpc/support/port_platform.h> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/iomgr/port.h" // IWYU pragma: keep |
||||
|
||||
#ifdef GRPC_POSIX_SOCKET |
||||
#include <unistd.h> |
||||
#endif |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
return std::make_unique<InsecureFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
// force tracing on, with a value to force many
|
||||
// code paths in trace.c to be taken
|
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.trace = "doesnt-exist,http,all"; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
#ifdef GRPC_POSIX_SOCKET |
||||
g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; |
||||
#else |
||||
g_fixture_slowdown_factor = 10; |
||||
#endif |
||||
|
||||
#ifdef GPR_WINDOWS |
||||
// on Windows, writing logs to stderr is very slow
|
||||
// when stderr is redirected to a disk file.
|
||||
// The "trace" tests fixtures generates large amount
|
||||
// of logs, so setting a buffer for stderr prevents certain
|
||||
// test cases from timing out.
|
||||
setvbuf(stderr, NULL, _IOLBF, 1024); |
||||
#endif |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0)); |
||||
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1)); |
||||
GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1)); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,58 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
return std::make_unique<InsecureFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,66 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
class NoRetryFixture : public InsecureFixture { |
||||
private: |
||||
grpc_core::ChannelArgs MutateClientArgs( |
||||
grpc_core::ChannelArgs args) override { |
||||
return args.Set(GRPC_ARG_ENABLE_RETRIES, false); |
||||
} |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
return std::make_unique<NoRetryFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,119 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2016 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <initializer_list> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/gprpp/host_port.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/http_proxy_fixture.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
class HttpProxyFilter : public CoreTestFixture { |
||||
public: |
||||
explicit HttpProxyFilter(const grpc_core::ChannelArgs& client_args) |
||||
: proxy_(grpc_end2end_http_proxy_create(client_args.ToC().get())) {} |
||||
~HttpProxyFilter() override { |
||||
// Need to shut down the proxy users before closing the proxy (otherwise we
|
||||
// become stuck).
|
||||
ShutdownClient(); |
||||
ShutdownServer(); |
||||
grpc_end2end_http_proxy_destroy(proxy_); |
||||
} |
||||
|
||||
private: |
||||
grpc_server* MakeServer(const grpc_core::ChannelArgs& args) override { |
||||
auto* server = grpc_server_create(args.ToC().get(), nullptr); |
||||
grpc_server_register_completion_queue(server, cq(), nullptr); |
||||
grpc_server_credentials* server_creds = |
||||
grpc_insecure_server_credentials_create(); |
||||
GPR_ASSERT( |
||||
grpc_server_add_http2_port(server, server_addr_.c_str(), server_creds)); |
||||
grpc_server_credentials_release(server_creds); |
||||
grpc_server_start(server); |
||||
return server; |
||||
} |
||||
|
||||
grpc_channel* MakeClient(const grpc_core::ChannelArgs& args) override { |
||||
// If testing for proxy auth, add credentials to proxy uri
|
||||
absl::optional<std::string> proxy_auth_str = |
||||
args.GetOwnedString(GRPC_ARG_HTTP_PROXY_AUTH_CREDS); |
||||
std::string proxy_uri; |
||||
if (!proxy_auth_str.has_value()) { |
||||
proxy_uri = absl::StrFormat( |
||||
"http://%s", grpc_end2end_http_proxy_get_proxy_name(proxy_)); |
||||
} else { |
||||
proxy_uri = |
||||
absl::StrFormat("http://%s@%s", proxy_auth_str->c_str(), |
||||
grpc_end2end_http_proxy_get_proxy_name(proxy_)); |
||||
} |
||||
grpc_channel_credentials* creds = grpc_insecure_credentials_create(); |
||||
auto* client = grpc_channel_create( |
||||
server_addr_.c_str(), creds, |
||||
args.Set(GRPC_ARG_HTTP_PROXY, proxy_uri).ToC().get()); |
||||
grpc_channel_credentials_release(creds); |
||||
GPR_ASSERT(client); |
||||
return client; |
||||
} |
||||
|
||||
std::string server_addr_ = |
||||
grpc_core::JoinHostPort("localhost", grpc_pick_unused_port_or_die()); |
||||
grpc_end2end_http_proxy* proxy_; |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& client_args, |
||||
const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<HttpProxyFilter>(client_args); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,84 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2020 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
namespace { |
||||
|
||||
void ProcessAuthFailure(void* state, grpc_auth_context* /*ctx*/, |
||||
const grpc_metadata* /*md*/, size_t /*md_count*/, |
||||
grpc_process_auth_metadata_done_cb cb, |
||||
void* user_data) { |
||||
GPR_ASSERT(state == nullptr); |
||||
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); |
||||
} |
||||
|
||||
class InsecureCredsFixture : public InsecureFixture { |
||||
private: |
||||
grpc_server_credentials* MakeServerCreds( |
||||
const grpc_core::ChannelArgs& args) override { |
||||
auto* creds = grpc_insecure_server_credentials_create(); |
||||
if (args.Contains(FAIL_AUTH_CHECK_SERVER_ARG_NAME)) { |
||||
grpc_auth_metadata_processor processor = {ProcessAuthFailure, nullptr, |
||||
nullptr}; |
||||
grpc_server_credentials_set_auth_metadata_processor(creds, processor); |
||||
} |
||||
return creds; |
||||
} |
||||
}; |
||||
|
||||
// All test configurations
|
||||
CoreTestConfiguration configs[] = { |
||||
{"chttp2/insecure_fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS_LEVEL_INSECURE, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<InsecureCredsFixture>(); |
||||
}}, |
||||
}; |
||||
|
||||
} // namespace
|
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,65 +0,0 @@ |
||||
// Copyright 2021 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <inttypes.h> |
||||
#include <unistd.h> |
||||
|
||||
#include <atomic> |
||||
#include <functional> |
||||
#include <initializer_list> |
||||
#include <memory> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/local_util.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::atomic<int> unique{0}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_local_abstract_uds_percent_encoded", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); |
||||
return std::make_unique<LocalTestFixture>( |
||||
absl::StrFormat("unix-abstract:grpc_fullstack_test.%%00.%d.%" PRId64 |
||||
".%" PRId32 ".%d", |
||||
getpid(), now.tv_sec, now.tv_nsec, |
||||
unique.fetch_add(1, std::memory_order_relaxed)), |
||||
UDS); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,59 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <unistd.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/gprpp/host_port.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/local_util.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_local_ipv4", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
int port = grpc_pick_unused_port_or_die(); |
||||
return std::make_unique<LocalTestFixture>( |
||||
grpc_core::JoinHostPort("127.0.0.1", port), LOCAL_TCP); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,59 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <unistd.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/gprpp/host_port.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/local_util.h" |
||||
#include "test/core/util/port.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_local_ipv6", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
int port = grpc_pick_unused_port_or_die(); |
||||
return std::make_unique<LocalTestFixture>( |
||||
grpc_core::JoinHostPort("[::1]", port), LOCAL_TCP); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,69 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <inttypes.h> |
||||
#include <unistd.h> |
||||
|
||||
#include <atomic> |
||||
#include <functional> |
||||
#include <initializer_list> |
||||
#include <memory> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/local_util.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::atomic<int> unique{1}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_local_uds", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); |
||||
return std::make_unique<LocalTestFixture>( |
||||
absl::StrFormat("unix:/tmp/grpc_fullstack_test.%d.%" PRId64 |
||||
".%" PRId32 ".%d", |
||||
getpid(), now.tv_sec, now.tv_nsec, |
||||
unique.fetch_add(1, std::memory_order_relaxed)), |
||||
UDS); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,69 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <inttypes.h> |
||||
#include <unistd.h> |
||||
|
||||
#include <atomic> |
||||
#include <functional> |
||||
#include <initializer_list> |
||||
#include <memory> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/local_util.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::atomic<int> unique{1}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_local_uds_percent_encoded", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& /*client_args*/, |
||||
const grpc_core::ChannelArgs& /*server_args*/) { |
||||
gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); |
||||
return std::make_unique<LocalTestFixture>( |
||||
absl::StrFormat("unix:/tmp/grpc_fullstack_test.%%25.%d.%" PRId64 |
||||
".%" PRId32 ".%d", |
||||
getpid(), now.tv_sec, now.tv_nsec, |
||||
unique.fetch_add(1, std::memory_order_relaxed)), |
||||
UDS); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,58 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <stdio.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_oauth2_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_with_oauth2_fullstack_tls1_2", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<Oauth2Fixture>(grpc_tls_version::TLS1_2); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,59 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <stdio.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_oauth2_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_with_oauth2_fullstack_tls1_3", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_DOES_NOT_SUPPORT_CLIENT_HANDSHAKE_COMPLETE_FIRST, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<Oauth2Fixture>(grpc_tls_version::TLS1_3); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,113 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/proxy.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
class ProxyFixture : public CoreTestFixture { |
||||
public: |
||||
ProxyFixture(const grpc_core::ChannelArgs& client_args, |
||||
const grpc_core::ChannelArgs& server_args) |
||||
: proxy_(grpc_end2end_proxy_create(&proxy_def_, client_args.ToC().get(), |
||||
server_args.ToC().get())) {} |
||||
~ProxyFixture() override { grpc_end2end_proxy_destroy(proxy_); } |
||||
|
||||
private: |
||||
static grpc_server* CreateProxyServer(const char* port, |
||||
const grpc_channel_args* server_args) { |
||||
grpc_server* s = grpc_server_create(server_args, nullptr); |
||||
grpc_server_credentials* server_creds = |
||||
grpc_insecure_server_credentials_create(); |
||||
GPR_ASSERT(grpc_server_add_http2_port(s, port, server_creds)); |
||||
grpc_server_credentials_release(server_creds); |
||||
return s; |
||||
} |
||||
|
||||
static grpc_channel* CreateProxyClient(const char* target, |
||||
const grpc_channel_args* client_args) { |
||||
grpc_channel_credentials* creds = grpc_insecure_credentials_create(); |
||||
grpc_channel* channel = grpc_channel_create(target, creds, client_args); |
||||
grpc_channel_credentials_release(creds); |
||||
return channel; |
||||
} |
||||
|
||||
grpc_server* MakeServer(const grpc_core::ChannelArgs& args) override { |
||||
auto* server = grpc_server_create(args.ToC().get(), nullptr); |
||||
grpc_server_register_completion_queue(server, cq(), nullptr); |
||||
grpc_server_credentials* server_creds = |
||||
grpc_insecure_server_credentials_create(); |
||||
GPR_ASSERT(grpc_server_add_http2_port( |
||||
server, grpc_end2end_proxy_get_server_port(proxy_), server_creds)); |
||||
grpc_server_credentials_release(server_creds); |
||||
grpc_server_start(server); |
||||
return server; |
||||
} |
||||
|
||||
grpc_channel* MakeClient(const grpc_core::ChannelArgs& args) override { |
||||
grpc_channel_credentials* creds = grpc_insecure_credentials_create(); |
||||
auto* client = grpc_channel_create( |
||||
grpc_end2end_proxy_get_client_target(proxy_), creds, args.ToC().get()); |
||||
grpc_channel_credentials_release(creds); |
||||
GPR_ASSERT(client); |
||||
return client; |
||||
} |
||||
const grpc_end2end_proxy_def proxy_def_ = {CreateProxyServer, |
||||
CreateProxyClient}; |
||||
grpc_end2end_proxy* proxy_; |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack+proxy", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs& client_args, |
||||
const grpc_core::ChannelArgs& server_args) { |
||||
return std::make_unique<ProxyFixture>(client_args, server_args); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,86 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "src/core/lib/iomgr/port.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/sockpair_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
#ifdef GRPC_POSIX_SOCKET |
||||
#include <unistd.h> |
||||
#endif |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/socketpair", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SockpairFixture>(grpc_core::ChannelArgs()); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
// force tracing on, with a value to force many
|
||||
// code paths in trace.cc to be taken
|
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.trace = "doesnt-exist,http,all"; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
#ifdef GRPC_POSIX_SOCKET |
||||
g_fixture_slowdown_factor = isatty(STDOUT_FILENO) ? 10 : 1; |
||||
#else |
||||
g_fixture_slowdown_factor = 10; |
||||
#endif |
||||
|
||||
#ifdef GPR_WINDOWS |
||||
// on Windows, writing logs to stderr is very slow
|
||||
// when stderr is redirected to a disk file.
|
||||
// The "trace" tests fixtures generates large amount
|
||||
// of logs, so setting a buffer for stderr prevents certain
|
||||
// test cases from timing out.
|
||||
setvbuf(stderr, NULL, _IOLBF, 1024); |
||||
#endif |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
GPR_ASSERT(0 == grpc_tracer_set_enabled("also-doesnt-exist", 0)); |
||||
GPR_ASSERT(1 == grpc_tracer_set_enabled("http", 1)); |
||||
GPR_ASSERT(1 == grpc_tracer_set_enabled("all", 1)); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,53 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/sockpair_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/socketpair", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SockpairFixture>(grpc_core::ChannelArgs()); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,59 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/sockpair_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/socketpair", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SockpairFixture>( |
||||
grpc_core::ChannelArgs() |
||||
.Set(GRPC_ARG_TCP_READ_CHUNK_SIZE, 1) |
||||
.Set(GRPC_ARG_TCP_MIN_READ_CHUNK_SIZE, 1) |
||||
.Set(GRPC_ARG_TCP_MAX_READ_CHUNK_SIZE, 1)); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
g_fixture_slowdown_factor = 2; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,72 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/sockpair_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
class SockpairWithMinstackFixture : public SockpairFixture { |
||||
public: |
||||
using SockpairFixture::SockpairFixture; |
||||
|
||||
private: |
||||
grpc_core::ChannelArgs MutateClientArgs( |
||||
grpc_core::ChannelArgs args) override { |
||||
return args.Set(GRPC_ARG_MINIMAL_STACK, true); |
||||
} |
||||
grpc_core::ChannelArgs MutateServerArgs( |
||||
grpc_core::ChannelArgs args) override { |
||||
return args.Set(GRPC_ARG_MINIMAL_STACK, true); |
||||
} |
||||
}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/socketpair+minstack", |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_DOES_NOT_SUPPORT_DEADLINES, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SockpairWithMinstackFixture>( |
||||
grpc_core::ChannelArgs()); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,68 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_fullstack_tls1_2", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SslCredReloadFixture>(TLS1_2); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = SslCredReloadFixture::CaCertPath(); |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,68 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_ssl_cred_reload_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_fullstack_tls1_3", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_DOES_NOT_SUPPORT_CLIENT_HANDSHAKE_COMPLETE_FIRST, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SslCredReloadFixture>(TLS1_3); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = SslCredReloadFixture::CaCertPath(); |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,188 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security.h> |
||||
#include <grpc/slice.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "src/core/lib/iomgr/error.h" |
||||
#include "src/core/lib/iomgr/exec_ctx.h" |
||||
#include "src/core/lib/iomgr/load_file.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/proxy.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
#define CA_CERT_PATH "src/core/tsi/test_creds/ca.pem" |
||||
#define SERVER_CERT_PATH "src/core/tsi/test_creds/server1.pem" |
||||
#define SERVER_KEY_PATH "src/core/tsi/test_creds/server1.key" |
||||
|
||||
static void process_auth_failure(void* state, grpc_auth_context* /*ctx*/, |
||||
const grpc_metadata* /*md*/, |
||||
size_t /*md_count*/, |
||||
grpc_process_auth_metadata_done_cb cb, |
||||
void* user_data) { |
||||
GPR_ASSERT(state == nullptr); |
||||
cb(user_data, nullptr, 0, nullptr, 0, GRPC_STATUS_UNAUTHENTICATED, nullptr); |
||||
} |
||||
|
||||
class SslProxyFixture : public CoreTestFixture { |
||||
public: |
||||
SslProxyFixture(const grpc_core::ChannelArgs& client_args, |
||||
const grpc_core::ChannelArgs& server_args) |
||||
: proxy_(grpc_end2end_proxy_create(&proxy_def_, client_args.ToC().get(), |
||||
server_args.ToC().get())) {} |
||||
~SslProxyFixture() override { grpc_end2end_proxy_destroy(proxy_); } |
||||
|
||||
private: |
||||
static grpc_server* CreateProxyServer(const char* port, |
||||
const grpc_channel_args* server_args) { |
||||
grpc_server* s = grpc_server_create(server_args, nullptr); |
||||
grpc_slice cert_slice, key_slice; |
||||
GPR_ASSERT(GRPC_LOG_IF_ERROR( |
||||
"load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice))); |
||||
GPR_ASSERT(GRPC_LOG_IF_ERROR( |
||||
"load_file", grpc_load_file(SERVER_KEY_PATH, 1, &key_slice))); |
||||
const char* server_cert = |
||||
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice); |
||||
const char* server_key = |
||||
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice); |
||||
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {server_key, server_cert}; |
||||
grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create( |
||||
nullptr, &pem_key_cert_pair, 1, 0, nullptr); |
||||
grpc_slice_unref(cert_slice); |
||||
grpc_slice_unref(key_slice); |
||||
GPR_ASSERT(grpc_server_add_http2_port(s, port, ssl_creds)); |
||||
grpc_server_credentials_release(ssl_creds); |
||||
return s; |
||||
} |
||||
|
||||
static grpc_channel* CreateProxyClient(const char* target, |
||||
const grpc_channel_args* client_args) { |
||||
grpc_channel* channel; |
||||
grpc_channel_credentials* ssl_creds = |
||||
grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); |
||||
grpc_arg ssl_name_override = { |
||||
GRPC_ARG_STRING, |
||||
const_cast<char*>(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG), |
||||
{const_cast<char*>("foo.test.google.fr")}}; |
||||
const grpc_channel_args* new_client_args = |
||||
grpc_channel_args_copy_and_add(client_args, &ssl_name_override, 1); |
||||
channel = grpc_channel_create(target, ssl_creds, new_client_args); |
||||
grpc_channel_credentials_release(ssl_creds); |
||||
{ |
||||
grpc_core::ExecCtx exec_ctx; |
||||
grpc_channel_args_destroy(new_client_args); |
||||
} |
||||
return channel; |
||||
} |
||||
|
||||
grpc_server* MakeServer(const grpc_core::ChannelArgs& args) override { |
||||
grpc_slice cert_slice, key_slice; |
||||
GPR_ASSERT(GRPC_LOG_IF_ERROR( |
||||
"load_file", grpc_load_file(SERVER_CERT_PATH, 1, &cert_slice))); |
||||
GPR_ASSERT(GRPC_LOG_IF_ERROR( |
||||
"load_file", grpc_load_file(SERVER_KEY_PATH, 1, &key_slice))); |
||||
const char* server_cert = |
||||
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(cert_slice); |
||||
const char* server_key = |
||||
reinterpret_cast<const char*> GRPC_SLICE_START_PTR(key_slice); |
||||
grpc_ssl_pem_key_cert_pair pem_key_cert_pair = {server_key, server_cert}; |
||||
grpc_server_credentials* ssl_creds = grpc_ssl_server_credentials_create( |
||||
nullptr, &pem_key_cert_pair, 1, 0, nullptr); |
||||
grpc_slice_unref(cert_slice); |
||||
grpc_slice_unref(key_slice); |
||||
if (args.Contains(FAIL_AUTH_CHECK_SERVER_ARG_NAME)) { |
||||
grpc_auth_metadata_processor processor = {process_auth_failure, nullptr, |
||||
nullptr}; |
||||
grpc_server_credentials_set_auth_metadata_processor(ssl_creds, processor); |
||||
} |
||||
|
||||
auto* server = grpc_server_create(args.ToC().get(), nullptr); |
||||
grpc_server_register_completion_queue(server, cq(), nullptr); |
||||
GPR_ASSERT(grpc_server_add_http2_port( |
||||
server, grpc_end2end_proxy_get_server_port(proxy_), ssl_creds)); |
||||
grpc_server_credentials_release(ssl_creds); |
||||
grpc_server_start(server); |
||||
return server; |
||||
} |
||||
|
||||
grpc_channel* MakeClient(const grpc_core::ChannelArgs& args) override { |
||||
grpc_channel_credentials* ssl_creds = |
||||
grpc_ssl_credentials_create(nullptr, nullptr, nullptr, nullptr); |
||||
auto* client = grpc_channel_create( |
||||
grpc_end2end_proxy_get_client_target(proxy_), ssl_creds, |
||||
args.Set(GRPC_SSL_TARGET_NAME_OVERRIDE_ARG, "foo.test.google.fr") |
||||
.ToC() |
||||
.get()); |
||||
GPR_ASSERT(client != nullptr); |
||||
grpc_channel_credentials_release(ssl_creds); |
||||
return client; |
||||
} |
||||
const grpc_end2end_proxy_def proxy_def_ = {CreateProxyServer, |
||||
CreateProxyClient}; |
||||
grpc_end2end_proxy* proxy_; |
||||
}; |
||||
|
||||
// All test configurations
|
||||
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_fullstack", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs& client_args, |
||||
const grpc_core::ChannelArgs& server_args) { |
||||
return std::make_unique<SslProxyFixture>(client_args, server_args); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
|
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = CA_CERT_PATH; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,65 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_ssl_tls_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_fullstack_tls1_2", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SslTlsFixture>(grpc_tls_version::TLS1_2); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = SslTlsFixture::CaCertPath(); |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,65 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/grpc_security_constants.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_ssl_tls_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/simple_ssl_fullstack_tls1_3", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER | |
||||
FEATURE_MASK_DOES_NOT_SUPPORT_CLIENT_HANDSHAKE_COMPLETE_FIRST, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<SslTlsFixture>(grpc_tls_version::TLS1_3); |
||||
}}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = SslTlsFixture::CaCertPath(); |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
|
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,58 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_tls_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static CoreTestConfiguration config = { |
||||
// client: certificate watcher provider + async external verifier
|
||||
// server: certificate watcher provider + async external verifier
|
||||
// extra: TLS 1.3
|
||||
"chttp2/cert_watcher_provider_async_verifier_tls1_3", |
||||
kH2TLSFeatureMask, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<TlsFixture>( |
||||
SecurityPrimitives::TlsVersion::V_13, |
||||
SecurityPrimitives::ProviderType::FILE_PROVIDER, |
||||
SecurityPrimitives::VerifierType::EXTERNAL_ASYNC_VERIFIER); |
||||
}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = CA_CERT_PATH; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
grpc_init(); |
||||
grpc_end2end_tests(argc, argv, config); |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,58 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_tls_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static CoreTestConfiguration config = { |
||||
// client: certificate watcher provider + hostname verifier
|
||||
// server: certificate watcher provider + sync external verifier
|
||||
// extra: TLS 1.2
|
||||
"chttp2/cert_watcher_provider_sync_verifier_tls1_2", |
||||
kH2TLSFeatureMask, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<TlsFixture>( |
||||
SecurityPrimitives::TlsVersion::V_12, |
||||
SecurityPrimitives::ProviderType::FILE_PROVIDER, |
||||
SecurityPrimitives::VerifierType::HOSTNAME_VERIFIER); |
||||
}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = CA_CERT_PATH; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
grpc_init(); |
||||
grpc_end2end_tests(argc, argv, config); |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,58 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_tls_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static CoreTestConfiguration config = { |
||||
// client: static data provider + sync external verifier
|
||||
// server: static data provider + sync external verifier
|
||||
// extra: TLS 1.2
|
||||
"chttp2/simple_ssl_fullstack", |
||||
kH2TLSFeatureMask, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<TlsFixture>( |
||||
SecurityPrimitives::TlsVersion::V_12, |
||||
SecurityPrimitives::ProviderType::STATIC_PROVIDER, |
||||
SecurityPrimitives::VerifierType::EXTERNAL_SYNC_VERIFIER); |
||||
}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = CA_CERT_PATH; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
grpc_init(); |
||||
grpc_end2end_tests(argc, argv, config); |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,58 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2018 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
#include <string> |
||||
|
||||
#include "absl/types/optional.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/config/config_vars.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/h2_tls_common.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static CoreTestConfiguration config = { |
||||
// client: static data provider + async external verifier
|
||||
// server: static data provider + async external verifier
|
||||
// extra: TLS 1.3
|
||||
"chttp2/static_provider_async_verifier_tls1_3", |
||||
kH2TLSFeatureMask, |
||||
"foo.test.google.fr", |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<TlsFixture>( |
||||
SecurityPrimitives::TlsVersion::V_13, |
||||
SecurityPrimitives::ProviderType::STATIC_PROVIDER, |
||||
SecurityPrimitives::VerifierType::EXTERNAL_ASYNC_VERIFIER); |
||||
}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_core::ConfigVars::Overrides overrides; |
||||
overrides.default_ssl_roots_file_path = CA_CERT_PATH; |
||||
grpc_core::ConfigVars::SetOverrides(overrides); |
||||
grpc_init(); |
||||
grpc_end2end_tests(argc, argv, config); |
||||
grpc_shutdown(); |
||||
return 0; |
||||
} |
@ -1,69 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <inttypes.h> |
||||
#include <unistd.h> |
||||
|
||||
#include <atomic> |
||||
#include <functional> |
||||
#include <initializer_list> |
||||
#include <memory> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::atomic<int> unique{1}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_uds", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); |
||||
return std::make_unique<InsecureFixture>(absl::StrFormat( |
||||
"unix:/tmp/grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 ".%d", |
||||
getpid(), now.tv_sec, now.tv_nsec, |
||||
unique.fetch_add(1, std::memory_order_relaxed))); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,69 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <inttypes.h> |
||||
#include <unistd.h> |
||||
|
||||
#include <atomic> |
||||
#include <functional> |
||||
#include <initializer_list> |
||||
#include <memory> |
||||
|
||||
#include "absl/strings/str_format.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/secure_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::atomic<int> unique{1}; |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = { |
||||
{"chttp2/fullstack_uds_abstract_namespace", |
||||
FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | |
||||
FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL | |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); |
||||
return std::make_unique<InsecureFixture>(absl::StrFormat( |
||||
"unix-abstract:grpc_fullstack_test.%d.%" PRId64 ".%" PRId32 ".%d", |
||||
getpid(), now.tv_sec, now.tv_nsec, |
||||
unique.fetch_add(1, std::memory_order_relaxed))); |
||||
}}, |
||||
}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,55 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2017 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/end2end/fixtures/inproc_fixture.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
// All test configurations
|
||||
static CoreTestConfiguration configs[] = {{ |
||||
"inproc", |
||||
FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, |
||||
nullptr, |
||||
[](const grpc_core::ChannelArgs&, const grpc_core::ChannelArgs&) { |
||||
return std::make_unique<InprocFixture>(); |
||||
}, |
||||
}}; |
||||
|
||||
int main(int argc, char** argv) { |
||||
size_t i; |
||||
|
||||
grpc::testing::TestEnvironment env(&argc, argv); |
||||
grpc_end2end_tests_pre_init(); |
||||
grpc_init(); |
||||
|
||||
for (i = 0; i < sizeof(configs) / sizeof(*configs); i++) { |
||||
grpc_end2end_tests(argc, argv, configs[i]); |
||||
} |
||||
|
||||
grpc_shutdown(); |
||||
|
||||
return 0; |
||||
} |
@ -1,53 +0,0 @@ |
||||
# Copyright 2015 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""Generates the list of end2end test cases from generate_tests.bzl""" |
||||
|
||||
import os |
||||
import sys |
||||
|
||||
import yaml |
||||
|
||||
_ROOT = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '../../..')) |
||||
os.chdir(_ROOT) |
||||
|
||||
|
||||
def load(*args): |
||||
"""Replacement of bazel's load() function""" |
||||
pass |
||||
|
||||
|
||||
def struct(**kwargs): |
||||
return kwargs # all the args as a dict |
||||
|
||||
|
||||
# generate_tests.bzl is now the source of truth for end2end tests. |
||||
# The .bzl file is basically a python file and we can "execute" it |
||||
# to get access to the variables it defines. |
||||
exec( |
||||
compile( |
||||
open('test/core/end2end/generate_tests.bzl', "rb").read(), |
||||
'test/core/end2end/generate_tests.bzl', 'exec')) |
||||
|
||||
|
||||
def main(): |
||||
json = { |
||||
# needed by end2end_tests.cc.template |
||||
'core_end2end_tests': |
||||
dict((t, END2END_TESTS[t]['secure']) for t in END2END_TESTS.keys()) |
||||
} |
||||
print(yaml.dump(json)) |
||||
|
||||
|
||||
if __name__ == '__main__': |
||||
main() |
@ -1,499 +0,0 @@ |
||||
#!/usr/bin/env python2.7 |
||||
# Copyright 2015 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
"""Generates the appropriate build.json data for all the end2end tests.""" |
||||
|
||||
load( |
||||
"//bazel:grpc_build_system.bzl", |
||||
"grpc_cc_binary", |
||||
"grpc_cc_library", |
||||
"grpc_sh_test", |
||||
) |
||||
load("flaky.bzl", "FLAKY_TESTS") |
||||
|
||||
def _fixture_options( |
||||
fullstack = True, |
||||
includes_proxy = False, |
||||
dns_resolver = True, |
||||
name_resolution = True, |
||||
secure = True, |
||||
tracing = False, |
||||
_platforms = ["windows", "linux", "mac", "posix"], |
||||
is_inproc = False, |
||||
is_1byte = False, |
||||
is_http2 = True, |
||||
is_minstack = False, |
||||
supports_proxy_auth = False, |
||||
supports_write_buffering = True, |
||||
client_channel = True, |
||||
supports_msvc = True, |
||||
supports_retry = None, |
||||
tags = []): |
||||
if supports_retry == None: |
||||
supports_retry = client_channel |
||||
return struct( |
||||
fullstack = fullstack, |
||||
includes_proxy = includes_proxy, |
||||
dns_resolver = dns_resolver, |
||||
name_resolution = name_resolution, |
||||
secure = secure, |
||||
tracing = tracing, |
||||
is_inproc = is_inproc, |
||||
is_1byte = is_1byte, |
||||
is_http2 = is_http2, |
||||
is_minstack = is_minstack, |
||||
supports_proxy_auth = supports_proxy_auth, |
||||
supports_write_buffering = supports_write_buffering, |
||||
client_channel = client_channel, |
||||
supports_msvc = supports_msvc, |
||||
_platforms = _platforms, |
||||
supports_retry = supports_retry, |
||||
tags = tags, |
||||
) |
||||
|
||||
# maps fixture name to whether it requires the security library |
||||
END2END_FIXTURES = { |
||||
"h2_compress": _fixture_options(), |
||||
"h2_census": _fixture_options(), |
||||
# TODO(juanlishen): This is disabled for now, but should be considered to re-enable once we have |
||||
# decided how the load reporting service should be enabled. |
||||
#'h2_load_reporting': _fixture_options(), |
||||
"h2_fakesec": _fixture_options(), |
||||
"h2_fd": _fixture_options( |
||||
dns_resolver = False, |
||||
fullstack = False, |
||||
client_channel = False, |
||||
_platforms = ["linux", "mac", "posix"], |
||||
tags = ["no_test_ios"], |
||||
), |
||||
"h2_full": _fixture_options( |
||||
tags = ["event_engine_client_test"], |
||||
), |
||||
"h2_full_no_retry": _fixture_options(supports_retry = False), |
||||
"h2_full+pipe": _fixture_options(_platforms = ["linux"]), |
||||
"h2_full+trace": _fixture_options(tracing = True), |
||||
"h2_http_proxy": _fixture_options(supports_proxy_auth = True), |
||||
"h2_insecure": _fixture_options(secure = True), |
||||
"h2_oauth2_tls12": _fixture_options(), |
||||
"h2_oauth2_tls13": _fixture_options(), |
||||
"h2_proxy": _fixture_options(includes_proxy = True), |
||||
"h2_sockpair_1byte": _fixture_options( |
||||
fullstack = False, |
||||
dns_resolver = False, |
||||
client_channel = False, |
||||
is_1byte = True, |
||||
), |
||||
"h2_sockpair": _fixture_options( |
||||
fullstack = False, |
||||
dns_resolver = False, |
||||
client_channel = False, |
||||
), |
||||
"h2_sockpair_with_minstack": _fixture_options( |
||||
fullstack = False, |
||||
dns_resolver = False, |
||||
client_channel = False, |
||||
is_minstack = True, |
||||
), |
||||
"h2_sockpair+trace": _fixture_options( |
||||
fullstack = False, |
||||
dns_resolver = False, |
||||
tracing = True, |
||||
client_channel = False, |
||||
), |
||||
"h2_ssl_tls12": _fixture_options(secure = True), |
||||
"h2_ssl_tls13": _fixture_options(secure = True), |
||||
"h2_ssl_cred_reload_tls12": _fixture_options(secure = True), |
||||
"h2_ssl_cred_reload_tls13": _fixture_options(secure = True), |
||||
"h2_tls_simple": _fixture_options(secure = True), |
||||
"h2_tls_static_async_tls1_3": _fixture_options(secure = True), |
||||
"h2_tls_certwatch_sync_tls1_2": _fixture_options(secure = True), |
||||
"h2_tls_certwatch_async_tls1_3": _fixture_options(secure = True), |
||||
"h2_local_abstract_uds_percent_encoded": _fixture_options( |
||||
secure = True, |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "posix"], |
||||
), |
||||
"h2_local_uds": _fixture_options( |
||||
secure = True, |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "mac", "posix"], |
||||
), |
||||
"h2_local_uds_percent_encoded": _fixture_options( |
||||
secure = True, |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "mac", "posix"], |
||||
), |
||||
"h2_local_ipv4": _fixture_options( |
||||
secure = True, |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "mac", "posix"], |
||||
tags = ["requires-net:ipv4", "requires-net:loopback", "event_engine_client"], |
||||
), |
||||
"h2_local_ipv6": _fixture_options( |
||||
secure = True, |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "mac", "posix"], |
||||
), |
||||
"h2_ssl_proxy": _fixture_options(includes_proxy = True, secure = True), |
||||
"h2_uds": _fixture_options( |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "mac", "posix"], |
||||
), |
||||
"h2_uds_abstract": _fixture_options( |
||||
dns_resolver = False, |
||||
_platforms = ["linux", "posix"], |
||||
), |
||||
"inproc": _fixture_options( |
||||
secure = True, |
||||
fullstack = False, |
||||
dns_resolver = False, |
||||
name_resolution = False, |
||||
is_inproc = True, |
||||
is_http2 = False, |
||||
supports_write_buffering = False, |
||||
client_channel = False, |
||||
), |
||||
} |
||||
|
||||
def _test_options( |
||||
needs_fullstack = False, |
||||
needs_dns = False, |
||||
needs_names = False, |
||||
proxyable = True, |
||||
secure = False, |
||||
traceable = False, |
||||
exclude_inproc = False, |
||||
exclude_1byte = False, |
||||
exclude_minstack = False, |
||||
needs_http2 = False, |
||||
needs_proxy_auth = False, |
||||
needs_write_buffering = False, |
||||
needs_client_channel = False, |
||||
needs_retry = False, |
||||
short_name = None, |
||||
tags = [], |
||||
exclude_pollers = []): |
||||
return struct( |
||||
needs_fullstack = needs_fullstack, |
||||
needs_dns = needs_dns, |
||||
needs_names = needs_names, |
||||
proxyable = proxyable, |
||||
secure = secure, |
||||
traceable = traceable, |
||||
exclude_inproc = exclude_inproc, |
||||
exclude_1byte = exclude_1byte, |
||||
exclude_minstack = exclude_minstack, |
||||
needs_http2 = needs_http2, |
||||
needs_proxy_auth = needs_proxy_auth, |
||||
needs_write_buffering = needs_write_buffering, |
||||
needs_client_channel = needs_client_channel, |
||||
needs_retry = needs_retry, |
||||
short_name = short_name, |
||||
tags = tags, |
||||
exclude_pollers = exclude_pollers, |
||||
) |
||||
|
||||
# maps test names to options |
||||
END2END_TESTS = { |
||||
"bad_hostname": _test_options(needs_names = True), |
||||
"bad_ping": _test_options(needs_fullstack = True, proxyable = False), |
||||
"binary_metadata": _test_options(), |
||||
"resource_quota_server": _test_options( |
||||
proxyable = False, |
||||
# TODO(b/151212019): Test case known to be flaky under epoll1. |
||||
exclude_pollers = ["epoll1"], |
||||
exclude_1byte = True, |
||||
), |
||||
"call_creds": _test_options(secure = True), |
||||
"call_host_override": _test_options( |
||||
needs_fullstack = True, |
||||
needs_dns = True, |
||||
needs_names = True, |
||||
), |
||||
"cancel_after_accept": _test_options(), |
||||
"cancel_after_client_done": _test_options(), |
||||
"cancel_after_invoke": _test_options(), |
||||
"cancel_after_round_trip": _test_options(), |
||||
"cancel_before_invoke": _test_options(), |
||||
"cancel_in_a_vacuum": _test_options(), |
||||
"cancel_with_status": _test_options(), |
||||
"client_streaming": _test_options(), |
||||
"compressed_payload": _test_options(proxyable = False, exclude_inproc = True, exclude_minstack = True), |
||||
"connectivity": _test_options( |
||||
needs_fullstack = True, |
||||
needs_names = True, |
||||
proxyable = False, |
||||
), |
||||
"channelz": _test_options(), |
||||
"default_host": _test_options( |
||||
needs_fullstack = True, |
||||
needs_dns = True, |
||||
needs_names = True, |
||||
), |
||||
"disappearing_server": _test_options(needs_fullstack = True, needs_names = True), |
||||
"empty_batch": _test_options(), |
||||
"filter_causes_close": _test_options(), |
||||
"filter_init_fails": _test_options(), |
||||
"filter_context": _test_options(), |
||||
"filtered_metadata": _test_options(), |
||||
"graceful_server_shutdown": _test_options(exclude_inproc = True), |
||||
"grpc_authz": _test_options(secure = True), |
||||
"hpack_size": _test_options( |
||||
proxyable = False, |
||||
traceable = False, |
||||
exclude_inproc = True, |
||||
), |
||||
"high_initial_seqno": _test_options(), |
||||
"invoke_large_request": _test_options(exclude_1byte = True, tags = ["flow_control_test"]), |
||||
"keepalive_timeout": _test_options(proxyable = False, needs_http2 = True), |
||||
"large_metadata": _test_options(exclude_1byte = True), |
||||
"max_concurrent_streams": _test_options( |
||||
proxyable = False, |
||||
exclude_inproc = True, |
||||
exclude_minstack = True, |
||||
), |
||||
"max_connection_age": _test_options(exclude_minstack = True, exclude_inproc = True), |
||||
"max_connection_idle": _test_options(needs_fullstack = True, proxyable = False), |
||||
"max_message_length": _test_options(exclude_minstack = True), |
||||
"negative_deadline": _test_options(exclude_minstack = True), |
||||
"no_logging": _test_options(traceable = False), |
||||
"no_op": _test_options(), |
||||
"payload": _test_options(exclude_1byte = True), |
||||
# TODO(juanlishen): This is disabled for now because it depends on some generated functions in |
||||
# end2end_tests.cc, which are not generated because they would depend on OpenCensus while |
||||
# OpenCensus can only be built via Bazel so far. |
||||
# 'load_reporting_hook': _test_options(), |
||||
"ping_pong_streaming": _test_options(tags = ["flow_control_test"]), |
||||
"ping": _test_options(needs_fullstack = True, proxyable = False), |
||||
"proxy_auth": _test_options(needs_proxy_auth = True), |
||||
"registered_call": _test_options(), |
||||
"request_with_flags": _test_options(proxyable = False), |
||||
"request_with_payload": _test_options(), |
||||
"retry": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_cancellation": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_cancel_during_delay": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_cancel_with_multiple_send_batches": _test_options( |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_cancel3", |
||||
needs_client_channel = True, |
||||
needs_retry = True, |
||||
), |
||||
"retry_cancel_after_first_attempt_starts": _test_options( |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_cancel4", |
||||
needs_client_channel = True, |
||||
needs_retry = True, |
||||
), |
||||
"retry_disabled": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_exceeds_buffer_size_in_delay": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_exceeds_buffer_size_in_initial_batch": _test_options( |
||||
needs_client_channel = True, |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_exceeds_buffer_size_in_init", |
||||
needs_retry = True, |
||||
), |
||||
"retry_exceeds_buffer_size_in_subsequent_batch": _test_options( |
||||
needs_client_channel = True, |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_exceeds_buffer_size_in_subseq", |
||||
needs_retry = True, |
||||
), |
||||
"retry_lb_drop": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_lb_fail": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_non_retriable_status": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_non_retriable_status_before_recv_trailing_metadata_started": _test_options( |
||||
needs_client_channel = True, |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_non_retriable_status2", |
||||
needs_retry = True, |
||||
), |
||||
"retry_per_attempt_recv_timeout": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_per_attempt_recv_timeout_on_last_attempt": _test_options( |
||||
needs_client_channel = True, |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_per_attempt_recv_timeout2", |
||||
needs_retry = True, |
||||
), |
||||
"retry_recv_initial_metadata": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_recv_message": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_recv_message_replay": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_recv_trailing_metadata_error": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_send_initial_metadata_refs": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_send_op_fails": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_send_recv_batch": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_server_pushback_delay": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_server_pushback_disabled": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_streaming": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_streaming_after_commit": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_streaming_succeeds_before_replay_finished": _test_options( |
||||
needs_client_channel = True, |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_streaming2", |
||||
needs_retry = True, |
||||
), |
||||
"retry_throttled": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_too_many_attempts": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_transparent_goaway": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_transparent_not_sent_on_wire": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_transparent_max_concurrent_streams": _test_options( |
||||
needs_client_channel = True, |
||||
proxyable = False, |
||||
# TODO(jtattermusch): too long bazel test name makes the test flaky on Windows RBE |
||||
# See b/151617965 |
||||
short_name = "retry_transparent_mcs", |
||||
needs_retry = True, |
||||
), |
||||
"retry_unref_before_finish": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"retry_unref_before_recv": _test_options(needs_client_channel = True, needs_retry = True), |
||||
"server_finishes_request": _test_options(), |
||||
"server_streaming": _test_options(needs_http2 = True), |
||||
"shutdown_finishes_calls": _test_options(), |
||||
"shutdown_finishes_tags": _test_options(), |
||||
"simple_delayed_request": _test_options(needs_fullstack = True), |
||||
"simple_metadata": _test_options(), |
||||
"simple_request": _test_options(), |
||||
"streaming_error_response": _test_options(), |
||||
"trailing_metadata": _test_options(), |
||||
"authority_not_supported": _test_options(), |
||||
"filter_latency": _test_options(), |
||||
"filter_status_code": _test_options(), |
||||
"write_buffering": _test_options(needs_write_buffering = True), |
||||
"write_buffering_at_end": _test_options(needs_write_buffering = True), |
||||
} |
||||
|
||||
def _compatible(fopt, topt): |
||||
if topt.needs_fullstack: |
||||
if not fopt.fullstack: |
||||
return False |
||||
if topt.needs_dns: |
||||
if not fopt.dns_resolver: |
||||
return False |
||||
if topt.needs_names: |
||||
if not fopt.name_resolution: |
||||
return False |
||||
if not topt.proxyable: |
||||
if fopt.includes_proxy: |
||||
return False |
||||
if not topt.traceable: |
||||
if fopt.tracing: |
||||
return False |
||||
if topt.exclude_inproc: |
||||
if fopt.is_inproc: |
||||
return False |
||||
if topt.exclude_1byte: |
||||
if fopt.is_1byte: |
||||
return False |
||||
if topt.exclude_minstack: |
||||
if fopt.is_minstack: |
||||
return False |
||||
if topt.needs_http2: |
||||
if not fopt.is_http2: |
||||
return False |
||||
if topt.needs_proxy_auth: |
||||
if not fopt.supports_proxy_auth: |
||||
return False |
||||
if topt.needs_write_buffering: |
||||
if not fopt.supports_write_buffering: |
||||
return False |
||||
if topt.needs_client_channel: |
||||
if not fopt.client_channel: |
||||
return False |
||||
if topt.needs_retry: |
||||
if not fopt.supports_retry: |
||||
return False |
||||
return True |
||||
|
||||
def _platform_support_tags(fopt): |
||||
result = [] |
||||
if not "windows" in fopt._platforms: |
||||
result.append("no_windows") |
||||
if not "mac" in fopt._platforms: |
||||
result.append("no_mac") |
||||
if not "linux" in fopt._platforms: |
||||
result.append("no_linux") |
||||
return result |
||||
|
||||
# buildifier: disable=unnamed-macro |
||||
def grpc_end2end_tests(): |
||||
"""Instantiates the gRPC end2end tests.""" |
||||
grpc_cc_library( |
||||
name = "end2end_tests", |
||||
srcs = ["end2end_tests.cc", "end2end_test_utils.cc"] + |
||||
["tests/%s.cc" % t for t in sorted(END2END_TESTS.keys())], |
||||
hdrs = [ |
||||
"tests/cancel_test_helpers.h", |
||||
"end2end_tests.h", |
||||
], |
||||
language = "C++", |
||||
testonly = 1, |
||||
deps = [ |
||||
":cq_verifier", |
||||
":ssl_test_data", |
||||
":http_proxy", |
||||
":proxy", |
||||
":fixture_support", |
||||
"//test/core/util:test_lb_policies", |
||||
"//:grpc_authorization_provider", |
||||
"//:grpc_http_filters", |
||||
"//src/core:event_log", |
||||
], |
||||
visibility = [ |
||||
"//src/objective-c/tests:__subpackages__", |
||||
], |
||||
) |
||||
for f, fopt in END2END_FIXTURES.items(): |
||||
bin_name = "%s_test" % f |
||||
grpc_cc_binary( |
||||
name = bin_name, |
||||
srcs = ["fixtures/%s.cc" % f, "fixtures/h2_tls_common.h"], |
||||
language = "C++", |
||||
testonly = 1, |
||||
data = [ |
||||
"//src/core/tsi/test_creds:ca.pem", |
||||
"//src/core/tsi/test_creds:server1.key", |
||||
"//src/core/tsi/test_creds:server1.pem", |
||||
], |
||||
deps = [ |
||||
":end2end_tests", |
||||
"//test/core/util:grpc_test_util", |
||||
"//:grpc", |
||||
"//:gpr", |
||||
"//:grpc_http_filters", |
||||
], |
||||
tags = _platform_support_tags(fopt) + fopt.tags, |
||||
) |
||||
for t, topt in END2END_TESTS.items(): |
||||
if not _compatible(fopt, topt): |
||||
continue |
||||
test_short_name = str(t) if not topt.short_name else topt.short_name |
||||
name = "%s_test@%s" % (f, test_short_name) |
||||
grpc_sh_test( |
||||
name = name, |
||||
srcs = ["run.sh"], |
||||
data = [":" + bin_name], |
||||
args = ["$(location %s)" % bin_name, t], |
||||
tags = _platform_support_tags(fopt) + fopt.tags + topt.tags + [ |
||||
"no_test_ios", |
||||
"core_end2end_test", |
||||
], |
||||
flaky = name in FLAKY_TESTS, |
||||
exclude_pollers = topt.exclude_pollers, |
||||
) |
@ -1,17 +0,0 @@ |
||||
#!/bin/sh |
||||
# Arbitrary shell script runner |
||||
# Copyright 2017 gRPC authors. |
||||
# |
||||
# Licensed under the Apache License, Version 2.0 (the "License"); |
||||
# you may not use this file except in compliance with the License. |
||||
# You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
set -ex |
||||
"$@" |
@ -1,142 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/byte_buffer.h> |
||||
#include <grpc/grpc.h> |
||||
#include <grpc/impl/propagation_bits.h> |
||||
#include <grpc/slice.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/cq_verifier.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::unique_ptr<CoreTestFixture> begin_test( |
||||
const CoreTestConfiguration& config, const char* test_name, |
||||
grpc_channel_args* client_args, grpc_channel_args* server_args) { |
||||
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); |
||||
auto f = config.create_fixture(grpc_core::ChannelArgs::FromC(client_args), |
||||
grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitServer(grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitClient(grpc_core::ChannelArgs::FromC(client_args)); |
||||
return f; |
||||
} |
||||
|
||||
// Request/response with metadata and payload.
|
||||
static void test_with_authority_header(const CoreTestConfiguration& config) { |
||||
grpc_call* c; |
||||
grpc_slice request_payload_slice = |
||||
grpc_slice_from_copied_string("hello world"); |
||||
grpc_byte_buffer* request_payload = |
||||
grpc_raw_byte_buffer_create(&request_payload_slice, 1); |
||||
grpc_metadata meta_c[2] = {{grpc_slice_from_static_string("key1"), |
||||
grpc_slice_from_static_string("val1"), |
||||
{{nullptr, nullptr, nullptr, nullptr}}}, |
||||
{grpc_slice_from_static_string("key2"), |
||||
grpc_slice_from_static_string("val2"), |
||||
{{nullptr, nullptr, nullptr, nullptr}}}}; |
||||
auto f = begin_test(config, "test_with_authority_header", nullptr, nullptr); |
||||
grpc_core::CqVerifier cqv(f->cq()); |
||||
grpc_op ops[6]; |
||||
grpc_op* op; |
||||
grpc_metadata_array initial_metadata_recv; |
||||
grpc_metadata_array trailing_metadata_recv; |
||||
grpc_byte_buffer* response_payload_recv = nullptr; |
||||
grpc_status_code status; |
||||
grpc_call_error error; |
||||
grpc_slice details; |
||||
|
||||
grpc_slice host = grpc_slice_from_static_string("foo.test.google.fr"); |
||||
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); |
||||
c = grpc_channel_create_call(f->client(), nullptr, GRPC_PROPAGATE_DEFAULTS, |
||||
f->cq(), grpc_slice_from_static_string("/foo"), |
||||
&host, deadline, nullptr); |
||||
GPR_ASSERT(c); |
||||
|
||||
grpc_metadata_array_init(&initial_metadata_recv); |
||||
grpc_metadata_array_init(&trailing_metadata_recv); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 2; |
||||
op->data.send_initial_metadata.metadata = meta_c; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_MESSAGE; |
||||
op->data.send_message.send_message = request_payload; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_INITIAL_METADATA; |
||||
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_MESSAGE; |
||||
op->data.recv_message.recv_message = &response_payload_recv; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; |
||||
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |
||||
op->data.recv_status_on_client.status = &status; |
||||
op->data.recv_status_on_client.status_details = &details; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), |
||||
grpc_core::CqVerifier::tag(1), nullptr); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
cqv.Expect(grpc_core::CqVerifier::tag(1), true); |
||||
cqv.Verify(); |
||||
|
||||
GPR_ASSERT(status == GRPC_STATUS_CANCELLED); |
||||
|
||||
grpc_slice_unref(details); |
||||
grpc_metadata_array_destroy(&initial_metadata_recv); |
||||
grpc_metadata_array_destroy(&trailing_metadata_recv); |
||||
|
||||
grpc_call_unref(c); |
||||
|
||||
grpc_byte_buffer_destroy(request_payload); |
||||
grpc_byte_buffer_destroy(response_payload_recv); |
||||
} |
||||
|
||||
void authority_not_supported(const CoreTestConfiguration& config) { |
||||
if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { |
||||
return; |
||||
} |
||||
test_with_authority_header(config); |
||||
} |
||||
|
||||
void authority_not_supported_pre_init(void) {} |
@ -1,124 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2015 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <string.h> |
||||
|
||||
#include <functional> |
||||
#include <memory> |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/impl/propagation_bits.h> |
||||
#include <grpc/slice.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "test/core/end2end/cq_verifier.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static std::unique_ptr<CoreTestFixture> begin_test( |
||||
const CoreTestConfiguration& config, const char* test_name, |
||||
grpc_channel_args* client_args, grpc_channel_args* server_args) { |
||||
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); |
||||
auto f = config.create_fixture(grpc_core::ChannelArgs::FromC(client_args), |
||||
grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitClient(grpc_core::ChannelArgs::FromC(client_args)); |
||||
f->InitServer(grpc_core::ChannelArgs::FromC(server_args)); |
||||
return f; |
||||
} |
||||
|
||||
static void simple_request_body(CoreTestFixture* f) { |
||||
grpc_call* c; |
||||
grpc_core::CqVerifier cqv(f->cq()); |
||||
grpc_op ops[6]; |
||||
grpc_op* op; |
||||
grpc_metadata_array initial_metadata_recv; |
||||
grpc_metadata_array trailing_metadata_recv; |
||||
grpc_metadata_array request_metadata_recv; |
||||
grpc_call_details call_details; |
||||
grpc_status_code status; |
||||
grpc_call_error error; |
||||
grpc_slice details; |
||||
|
||||
grpc_slice host = grpc_slice_from_static_string("slartibartfast.local"); |
||||
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); |
||||
c = grpc_channel_create_call(f->client(), nullptr, GRPC_PROPAGATE_DEFAULTS, |
||||
f->cq(), grpc_slice_from_static_string("/foo"), |
||||
&host, deadline, nullptr); |
||||
GPR_ASSERT(c); |
||||
|
||||
grpc_metadata_array_init(&initial_metadata_recv); |
||||
grpc_metadata_array_init(&trailing_metadata_recv); |
||||
grpc_metadata_array_init(&request_metadata_recv); |
||||
grpc_call_details_init(&call_details); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 0; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_INITIAL_METADATA; |
||||
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; |
||||
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |
||||
op->data.recv_status_on_client.status = &status; |
||||
op->data.recv_status_on_client.status_details = &details; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), |
||||
grpc_core::CqVerifier::tag(1), nullptr); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
cqv.Expect(grpc_core::CqVerifier::tag(1), true); |
||||
cqv.Verify(); |
||||
|
||||
GPR_ASSERT(status == GRPC_STATUS_INTERNAL); |
||||
|
||||
grpc_slice_unref(details); |
||||
grpc_metadata_array_destroy(&initial_metadata_recv); |
||||
grpc_metadata_array_destroy(&trailing_metadata_recv); |
||||
grpc_metadata_array_destroy(&request_metadata_recv); |
||||
grpc_call_details_destroy(&call_details); |
||||
|
||||
grpc_call_unref(c); |
||||
} |
||||
|
||||
static void test_invoke_simple_request(const CoreTestConfiguration& config) { |
||||
auto f = begin_test(config, "test_invoke_simple_request", nullptr, nullptr); |
||||
simple_request_body(f.get()); |
||||
} |
||||
|
||||
void bad_hostname(const CoreTestConfiguration& config) { |
||||
if (config.feature_mask & FEATURE_MASK_SUPPORTS_HOSTNAME_VERIFICATION) { |
||||
test_invoke_simple_request(config); |
||||
} |
||||
} |
||||
|
||||
void bad_hostname_pre_init(void) {} |
@ -1,289 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2016 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
#include <limits.h> |
||||
#include <string.h> |
||||
|
||||
#include <algorithm> |
||||
#include <functional> |
||||
#include <memory> |
||||
#include <vector> |
||||
|
||||
#include "absl/status/status.h" |
||||
|
||||
#include <grpc/byte_buffer.h> |
||||
#include <grpc/grpc.h> |
||||
#include <grpc/impl/propagation_bits.h> |
||||
#include <grpc/slice.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/sync.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/channel/channel_fwd.h" |
||||
#include "src/core/lib/channel/channel_stack.h" |
||||
#include "src/core/lib/channel/channel_stack_builder.h" |
||||
#include "src/core/lib/config/core_configuration.h" |
||||
#include "src/core/lib/iomgr/closure.h" |
||||
#include "src/core/lib/iomgr/error.h" |
||||
#include "src/core/lib/surface/channel_stack_type.h" |
||||
#include "test/core/end2end/cq_verifier.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
enum { TIMEOUT = 200000 }; |
||||
|
||||
static gpr_mu g_mu; |
||||
static gpr_timespec g_client_latency; |
||||
static gpr_timespec g_server_latency; |
||||
|
||||
static std::unique_ptr<CoreTestFixture> begin_test( |
||||
const CoreTestConfiguration& config, const char* test_name, |
||||
grpc_channel_args* client_args, grpc_channel_args* server_args) { |
||||
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); |
||||
auto f = config.create_fixture(grpc_core::ChannelArgs::FromC(client_args), |
||||
grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitServer(grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitClient(grpc_core::ChannelArgs::FromC(client_args)); |
||||
return f; |
||||
} |
||||
|
||||
// Simple request via a server filter that saves the reported latency value.
|
||||
static void test_request(const CoreTestConfiguration& config) { |
||||
grpc_call* c; |
||||
grpc_call* s; |
||||
grpc_slice request_payload_slice = |
||||
grpc_slice_from_copied_string("hello world"); |
||||
grpc_byte_buffer* request_payload = |
||||
grpc_raw_byte_buffer_create(&request_payload_slice, 1); |
||||
auto f = begin_test(config, "filter_latency", nullptr, nullptr); |
||||
grpc_core::CqVerifier cqv(f->cq()); |
||||
grpc_op ops[6]; |
||||
grpc_op* op; |
||||
grpc_metadata_array initial_metadata_recv; |
||||
grpc_metadata_array trailing_metadata_recv; |
||||
grpc_metadata_array request_metadata_recv; |
||||
grpc_byte_buffer* request_payload_recv = nullptr; |
||||
grpc_call_details call_details; |
||||
grpc_status_code status; |
||||
grpc_call_error error; |
||||
grpc_slice details; |
||||
int was_cancelled = 2; |
||||
|
||||
gpr_mu_lock(&g_mu); |
||||
g_client_latency = gpr_time_0(GPR_TIMESPAN); |
||||
g_server_latency = gpr_time_0(GPR_TIMESPAN); |
||||
gpr_mu_unlock(&g_mu); |
||||
const gpr_timespec start_time = gpr_now(GPR_CLOCK_REALTIME); |
||||
|
||||
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); |
||||
c = grpc_channel_create_call(f->client(), nullptr, GRPC_PROPAGATE_DEFAULTS, |
||||
f->cq(), grpc_slice_from_static_string("/foo"), |
||||
nullptr, deadline, nullptr); |
||||
GPR_ASSERT(c); |
||||
|
||||
grpc_metadata_array_init(&initial_metadata_recv); |
||||
grpc_metadata_array_init(&trailing_metadata_recv); |
||||
grpc_metadata_array_init(&request_metadata_recv); |
||||
grpc_call_details_init(&call_details); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 0; |
||||
op->data.send_initial_metadata.metadata = nullptr; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_MESSAGE; |
||||
op->data.send_message.send_message = request_payload; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_INITIAL_METADATA; |
||||
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; |
||||
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |
||||
op->data.recv_status_on_client.status = &status; |
||||
op->data.recv_status_on_client.status_details = &details; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), |
||||
grpc_core::CqVerifier::tag(1), nullptr); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
error = grpc_server_request_call(f->server(), &s, &call_details, |
||||
&request_metadata_recv, f->cq(), f->cq(), |
||||
grpc_core::CqVerifier::tag(101)); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
cqv.Expect(grpc_core::CqVerifier::tag(101), true); |
||||
cqv.Verify(); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 0; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; |
||||
op->data.send_status_from_server.trailing_metadata_count = 0; |
||||
op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; |
||||
grpc_slice status_string = grpc_slice_from_static_string("xyz"); |
||||
op->data.send_status_from_server.status_details = &status_string; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; |
||||
op->data.recv_close_on_server.cancelled = &was_cancelled; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), |
||||
grpc_core::CqVerifier::tag(102), nullptr); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
cqv.Expect(grpc_core::CqVerifier::tag(102), true); |
||||
cqv.Expect(grpc_core::CqVerifier::tag(1), true); |
||||
cqv.Verify(); |
||||
|
||||
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); |
||||
GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); |
||||
|
||||
grpc_slice_unref(details); |
||||
grpc_metadata_array_destroy(&initial_metadata_recv); |
||||
grpc_metadata_array_destroy(&trailing_metadata_recv); |
||||
grpc_metadata_array_destroy(&request_metadata_recv); |
||||
grpc_call_details_destroy(&call_details); |
||||
|
||||
grpc_call_unref(s); |
||||
grpc_call_unref(c); |
||||
|
||||
grpc_byte_buffer_destroy(request_payload); |
||||
grpc_byte_buffer_destroy(request_payload_recv); |
||||
|
||||
const gpr_timespec end_time = gpr_now(GPR_CLOCK_REALTIME); |
||||
const gpr_timespec max_latency = gpr_time_sub(end_time, start_time); |
||||
|
||||
// Perform checks after test tear-down
|
||||
// Guards against the case that there's outstanding channel-related work on a
|
||||
// call prior to verification
|
||||
gpr_mu_lock(&g_mu); |
||||
GPR_ASSERT(gpr_time_cmp(max_latency, g_client_latency) >= 0); |
||||
GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_client_latency) <= 0); |
||||
GPR_ASSERT(gpr_time_cmp(max_latency, g_server_latency) >= 0); |
||||
GPR_ASSERT(gpr_time_cmp(gpr_time_0(GPR_TIMESPAN), g_server_latency) <= 0); |
||||
// Server latency should always be smaller than client latency, however since
|
||||
// we only calculate latency at destruction time, and that might mean that we
|
||||
// need to wait for outstanding channel-related work, this isn't verifiable
|
||||
// right now (the server MAY hold on to the call for longer than the client).
|
||||
// GPR_ASSERT(gpr_time_cmp(g_server_latency, g_client_latency) < 0);
|
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
//******************************************************************************
|
||||
// Test latency filter
|
||||
//
|
||||
|
||||
static grpc_error_handle init_call_elem( |
||||
grpc_call_element* /*elem*/, const grpc_call_element_args* /*args*/) { |
||||
return absl::OkStatus(); |
||||
} |
||||
|
||||
static void client_destroy_call_elem(grpc_call_element* /*elem*/, |
||||
const grpc_call_final_info* final_info, |
||||
grpc_closure* /*ignored*/) { |
||||
gpr_mu_lock(&g_mu); |
||||
g_client_latency = final_info->stats.latency; |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
static void server_destroy_call_elem(grpc_call_element* /*elem*/, |
||||
const grpc_call_final_info* final_info, |
||||
grpc_closure* /*ignored*/) { |
||||
gpr_mu_lock(&g_mu); |
||||
g_server_latency = final_info->stats.latency; |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
static grpc_error_handle init_channel_elem( |
||||
grpc_channel_element* /*elem*/, grpc_channel_element_args* /*args*/) { |
||||
return absl::OkStatus(); |
||||
} |
||||
|
||||
static void destroy_channel_elem(grpc_channel_element* /*elem*/) {} |
||||
|
||||
static const grpc_channel_filter test_client_filter = { |
||||
grpc_call_next_op, nullptr, |
||||
grpc_channel_next_op, 0, |
||||
init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, |
||||
client_destroy_call_elem, 0, |
||||
init_channel_elem, grpc_channel_stack_no_post_init, |
||||
destroy_channel_elem, grpc_channel_next_get_info, |
||||
"client_filter_latency"}; |
||||
|
||||
static const grpc_channel_filter test_server_filter = { |
||||
grpc_call_next_op, nullptr, |
||||
grpc_channel_next_op, 0, |
||||
init_call_elem, grpc_call_stack_ignore_set_pollset_or_pollset_set, |
||||
server_destroy_call_elem, 0, |
||||
init_channel_elem, grpc_channel_stack_no_post_init, |
||||
destroy_channel_elem, grpc_channel_next_get_info, |
||||
"server_filter_latency"}; |
||||
|
||||
//******************************************************************************
|
||||
// Registration
|
||||
//
|
||||
|
||||
void filter_latency(const CoreTestConfiguration& config) { |
||||
grpc_core::CoreConfiguration::RunWithSpecialConfiguration( |
||||
[](grpc_core::CoreConfiguration::Builder* builder) { |
||||
grpc_core::BuildCoreConfiguration(builder); |
||||
auto register_stage = [builder](grpc_channel_stack_type type, |
||||
const grpc_channel_filter* filter) { |
||||
builder->channel_init()->RegisterStage( |
||||
type, INT_MAX, [filter](grpc_core::ChannelStackBuilder* builder) { |
||||
// Want to add the filter as close to the end as possible, to
|
||||
// make sure that all of the filters work well together.
|
||||
// However, we can't add it at the very end, because the
|
||||
// connected channel filter must be the last one. So we add it
|
||||
// right before the last one.
|
||||
auto it = builder->mutable_stack()->end(); |
||||
--it; |
||||
builder->mutable_stack()->insert(it, filter); |
||||
return true; |
||||
}); |
||||
}; |
||||
register_stage(GRPC_CLIENT_CHANNEL, &test_client_filter); |
||||
register_stage(GRPC_CLIENT_DIRECT_CHANNEL, &test_client_filter); |
||||
register_stage(GRPC_SERVER_CHANNEL, &test_server_filter); |
||||
}, |
||||
[config] { test_request(config); }); |
||||
} |
||||
|
||||
void filter_latency_pre_init(void) { gpr_mu_init(&g_mu); } |
@ -1,353 +0,0 @@ |
||||
//
|
||||
//
|
||||
// Copyright 2017 gRPC authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//
|
||||
|
||||
// This test verifies -
|
||||
// 1) grpc_call_final_info passed to the filters on destroying a call contains
|
||||
// the proper status.
|
||||
// 2) If the response has both an HTTP status code and a gRPC status code, then
|
||||
// we should prefer the gRPC status code as mentioned in
|
||||
// https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md
|
||||
//
|
||||
|
||||
#include <limits.h> |
||||
#include <string.h> |
||||
|
||||
#include <algorithm> |
||||
#include <functional> |
||||
#include <memory> |
||||
#include <vector> |
||||
|
||||
#include "absl/status/status.h" |
||||
|
||||
#include <grpc/grpc.h> |
||||
#include <grpc/impl/propagation_bits.h> |
||||
#include <grpc/slice.h> |
||||
#include <grpc/status.h> |
||||
#include <grpc/support/log.h> |
||||
#include <grpc/support/sync.h> |
||||
#include <grpc/support/time.h> |
||||
|
||||
#include "src/core/lib/channel/channel_args.h" |
||||
#include "src/core/lib/channel/channel_fwd.h" |
||||
#include "src/core/lib/channel/channel_stack.h" |
||||
#include "src/core/lib/channel/channel_stack_builder.h" |
||||
#include "src/core/lib/config/core_configuration.h" |
||||
#include "src/core/lib/iomgr/closure.h" |
||||
#include "src/core/lib/iomgr/error.h" |
||||
#include "src/core/lib/surface/call.h" |
||||
#include "src/core/lib/surface/channel_stack_type.h" |
||||
#include "src/core/lib/transport/metadata_batch.h" |
||||
#include "src/core/lib/transport/transport.h" |
||||
#include "test/core/end2end/cq_verifier.h" |
||||
#include "test/core/end2end/end2end_tests.h" |
||||
#include "test/core/util/test_config.h" |
||||
|
||||
static gpr_mu g_mu; |
||||
static grpc_call_stack* g_client_call_stack; |
||||
static grpc_call_stack* g_server_call_stack; |
||||
static bool g_client_code_recv; |
||||
static bool g_server_code_recv; |
||||
static gpr_cv g_client_code_cv; |
||||
static gpr_cv g_server_code_cv; |
||||
static grpc_status_code g_client_status_code; |
||||
static grpc_status_code g_server_status_code; |
||||
|
||||
static std::unique_ptr<CoreTestFixture> begin_test( |
||||
const CoreTestConfiguration& config, const char* test_name, |
||||
grpc_channel_args* client_args, grpc_channel_args* server_args) { |
||||
gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); |
||||
auto f = config.create_fixture(grpc_core::ChannelArgs::FromC(client_args), |
||||
grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitServer(grpc_core::ChannelArgs::FromC(server_args)); |
||||
f->InitClient(grpc_core::ChannelArgs::FromC(client_args)); |
||||
return f; |
||||
} |
||||
|
||||
// Simple request via a server filter that saves the reported status code.
|
||||
static void test_request(const CoreTestConfiguration& config) { |
||||
g_client_code_recv = false; |
||||
g_server_code_recv = false; |
||||
|
||||
grpc_call* c; |
||||
grpc_call* s; |
||||
auto f = begin_test(config, "filter_status_code", nullptr, nullptr); |
||||
grpc_core::CqVerifier cqv(f->cq()); |
||||
grpc_op ops[6]; |
||||
grpc_op* op; |
||||
grpc_metadata_array initial_metadata_recv; |
||||
grpc_metadata_array trailing_metadata_recv; |
||||
grpc_metadata_array request_metadata_recv; |
||||
grpc_call_details call_details; |
||||
grpc_status_code status; |
||||
grpc_call_error error; |
||||
grpc_slice details; |
||||
int was_cancelled = 2; |
||||
|
||||
gpr_mu_lock(&g_mu); |
||||
g_client_call_stack = nullptr; |
||||
g_server_call_stack = nullptr; |
||||
g_client_status_code = GRPC_STATUS_OK; |
||||
g_server_status_code = GRPC_STATUS_OK; |
||||
gpr_mu_unlock(&g_mu); |
||||
|
||||
gpr_timespec deadline = grpc_timeout_seconds_to_deadline(5); |
||||
c = grpc_channel_create_call(f->client(), nullptr, GRPC_PROPAGATE_DEFAULTS, |
||||
f->cq(), grpc_slice_from_static_string("/foo"), |
||||
nullptr, deadline, nullptr); |
||||
GPR_ASSERT(c); |
||||
gpr_mu_lock(&g_mu); |
||||
g_client_call_stack = grpc_call_get_call_stack(c); |
||||
gpr_mu_unlock(&g_mu); |
||||
|
||||
grpc_metadata_array_init(&initial_metadata_recv); |
||||
grpc_metadata_array_init(&trailing_metadata_recv); |
||||
grpc_metadata_array_init(&request_metadata_recv); |
||||
grpc_call_details_init(&call_details); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 0; |
||||
op->data.send_initial_metadata.metadata = nullptr; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_INITIAL_METADATA; |
||||
op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; |
||||
op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; |
||||
op->data.recv_status_on_client.status = &status; |
||||
op->data.recv_status_on_client.status_details = &details; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
error = grpc_call_start_batch(c, ops, static_cast<size_t>(op - ops), |
||||
grpc_core::CqVerifier::tag(1), nullptr); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
error = grpc_server_request_call(f->server(), &s, &call_details, |
||||
&request_metadata_recv, f->cq(), f->cq(), |
||||
grpc_core::CqVerifier::tag(101)); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
cqv.Expect(grpc_core::CqVerifier::tag(101), true); |
||||
cqv.Verify(); |
||||
|
||||
gpr_mu_lock(&g_mu); |
||||
g_server_call_stack = grpc_call_get_call_stack(s); |
||||
gpr_mu_unlock(&g_mu); |
||||
|
||||
memset(ops, 0, sizeof(ops)); |
||||
op = ops; |
||||
op->op = GRPC_OP_SEND_INITIAL_METADATA; |
||||
op->data.send_initial_metadata.count = 0; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; |
||||
op->data.send_status_from_server.trailing_metadata_count = 0; |
||||
op->data.send_status_from_server.status = GRPC_STATUS_UNIMPLEMENTED; |
||||
grpc_slice status_string = grpc_slice_from_static_string("xyz"); |
||||
op->data.send_status_from_server.status_details = &status_string; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; |
||||
op->data.recv_close_on_server.cancelled = &was_cancelled; |
||||
op->flags = 0; |
||||
op->reserved = nullptr; |
||||
op++; |
||||
error = grpc_call_start_batch(s, ops, static_cast<size_t>(op - ops), |
||||
grpc_core::CqVerifier::tag(102), nullptr); |
||||
GPR_ASSERT(GRPC_CALL_OK == error); |
||||
|
||||
cqv.Expect(grpc_core::CqVerifier::tag(102), true); |
||||
cqv.Expect(grpc_core::CqVerifier::tag(1), true); |
||||
cqv.Verify(); |
||||
|
||||
GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); |
||||
GPR_ASSERT(0 == grpc_slice_str_cmp(details, "xyz")); |
||||
|
||||
grpc_slice_unref(details); |
||||
grpc_metadata_array_destroy(&initial_metadata_recv); |
||||
grpc_metadata_array_destroy(&trailing_metadata_recv); |
||||
grpc_metadata_array_destroy(&request_metadata_recv); |
||||
grpc_call_details_destroy(&call_details); |
||||
|
||||
grpc_call_unref(s); |
||||
grpc_call_unref(c); |
||||
|
||||
// Perform checks after test tear-down
|
||||
// Guards against the case that there's outstanding channel-related work on a
|
||||
// call prior to verification
|
||||
gpr_mu_lock(&g_mu); |
||||
if (!g_client_code_recv) { |
||||
GPR_ASSERT(gpr_cv_wait(&g_client_code_cv, &g_mu, |
||||
grpc_timeout_seconds_to_deadline(3)) == 0); |
||||
} |
||||
if (!g_server_code_recv) { |
||||
GPR_ASSERT(gpr_cv_wait(&g_server_code_cv, &g_mu, |
||||
grpc_timeout_seconds_to_deadline(3)) == 0); |
||||
} |
||||
GPR_ASSERT(g_client_status_code == GRPC_STATUS_UNIMPLEMENTED); |
||||
GPR_ASSERT(g_server_status_code == GRPC_STATUS_UNIMPLEMENTED); |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
//******************************************************************************
|
||||
// Test status_code filter
|
||||
//
|
||||
|
||||
typedef struct final_status_data { |
||||
grpc_call_stack* call; |
||||
} final_status_data; |
||||
|
||||
static void server_start_transport_stream_op_batch( |
||||
grpc_call_element* elem, grpc_transport_stream_op_batch* op) { |
||||
auto* data = static_cast<final_status_data*>(elem->call_data); |
||||
gpr_mu_lock(&g_mu); |
||||
if (data->call == g_server_call_stack) { |
||||
if (op->send_initial_metadata) { |
||||
auto* batch = op->payload->send_initial_metadata.send_initial_metadata; |
||||
auto* status = batch->get_pointer(grpc_core::HttpStatusMetadata()); |
||||
if (status != nullptr) { |
||||
// Replace the HTTP status with 404
|
||||
*status = 404; |
||||
} |
||||
} |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
grpc_call_next_op(elem, op); |
||||
} |
||||
|
||||
static grpc_error_handle init_call_elem(grpc_call_element* elem, |
||||
const grpc_call_element_args* args) { |
||||
final_status_data* data = static_cast<final_status_data*>(elem->call_data); |
||||
data->call = args->call_stack; |
||||
return absl::OkStatus(); |
||||
} |
||||
|
||||
static void client_destroy_call_elem(grpc_call_element* elem, |
||||
const grpc_call_final_info* final_info, |
||||
grpc_closure* /*ignored*/) { |
||||
final_status_data* data = static_cast<final_status_data*>(elem->call_data); |
||||
gpr_mu_lock(&g_mu); |
||||
// Some fixtures, like proxies, will spawn intermidiate calls
|
||||
// We only want the results from our explicit calls
|
||||
if (data->call == g_client_call_stack) { |
||||
g_client_status_code = final_info->final_status; |
||||
g_client_code_recv = true; |
||||
gpr_cv_signal(&g_client_code_cv); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
static void server_destroy_call_elem(grpc_call_element* elem, |
||||
const grpc_call_final_info* final_info, |
||||
grpc_closure* /*ignored*/) { |
||||
final_status_data* data = static_cast<final_status_data*>(elem->call_data); |
||||
gpr_mu_lock(&g_mu); |
||||
// Some fixtures, like proxies, will spawn intermidiate calls
|
||||
// We only want the results from our explicit calls
|
||||
if (data->call == g_server_call_stack) { |
||||
g_server_status_code = final_info->final_status; |
||||
g_server_code_recv = true; |
||||
gpr_cv_signal(&g_server_code_cv); |
||||
} |
||||
gpr_mu_unlock(&g_mu); |
||||
} |
||||
|
||||
static grpc_error_handle init_channel_elem( |
||||
grpc_channel_element* /*elem*/, grpc_channel_element_args* /*args*/) { |
||||
return absl::OkStatus(); |
||||
} |
||||
|
||||
static void destroy_channel_elem(grpc_channel_element* /*elem*/) {} |
||||
|
||||
static const grpc_channel_filter test_client_filter = { |
||||
grpc_call_next_op, |
||||
nullptr, |
||||
grpc_channel_next_op, |
||||
sizeof(final_status_data), |
||||
init_call_elem, |
||||
grpc_call_stack_ignore_set_pollset_or_pollset_set, |
||||
client_destroy_call_elem, |
||||
0, |
||||
init_channel_elem, |
||||
grpc_channel_stack_no_post_init, |
||||
destroy_channel_elem, |
||||
grpc_channel_next_get_info, |
||||
"client_filter_status_code"}; |
||||
|
||||
static const grpc_channel_filter test_server_filter = { |
||||
server_start_transport_stream_op_batch, |
||||
nullptr, |
||||
grpc_channel_next_op, |
||||
sizeof(final_status_data), |
||||
init_call_elem, |
||||
grpc_call_stack_ignore_set_pollset_or_pollset_set, |
||||
server_destroy_call_elem, |
||||
0, |
||||
init_channel_elem, |
||||
grpc_channel_stack_no_post_init, |
||||
destroy_channel_elem, |
||||
grpc_channel_next_get_info, |
||||
"server_filter_status_code"}; |
||||
|
||||
//******************************************************************************
|
||||
// Registration
|
||||
//
|
||||
|
||||
void filter_status_code(const CoreTestConfiguration& config) { |
||||
grpc_core::CoreConfiguration::RunWithSpecialConfiguration( |
||||
[](grpc_core::CoreConfiguration::Builder* builder) { |
||||
grpc_core::BuildCoreConfiguration(builder); |
||||
auto register_stage = [builder](grpc_channel_stack_type type, |
||||
const grpc_channel_filter* filter) { |
||||
builder->channel_init()->RegisterStage( |
||||
type, INT_MAX, [filter](grpc_core::ChannelStackBuilder* builder) { |
||||
// Want to add the filter as close to the end as possible, to
|
||||
// make sure that all of the filters work well together.
|
||||
// However, we can't add it at the very end, because the
|
||||
// connected_channel/client_channel filter must be the last one.
|
||||
// So we add it right before the last one.
|
||||
auto it = builder->mutable_stack()->end(); |
||||
--it; |
||||
builder->mutable_stack()->insert(it, filter); |
||||
return true; |
||||
}); |
||||
}; |
||||
register_stage(GRPC_CLIENT_CHANNEL, &test_client_filter); |
||||
register_stage(GRPC_CLIENT_DIRECT_CHANNEL, &test_client_filter); |
||||
register_stage(GRPC_SERVER_CHANNEL, &test_server_filter); |
||||
}, |
||||
[&config] { test_request(config); }); |
||||
} |
||||
|
||||
void filter_status_code_pre_init(void) { |
||||
gpr_mu_init(&g_mu); |
||||
gpr_cv_init(&g_client_code_cv); |
||||
gpr_cv_init(&g_server_code_cv); |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue