aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/core/end2end/dualstack_socket_test.c4
-rw-r--r--test/core/iomgr/alarm_test.c9
-rw-r--r--test/core/iomgr/endpoint_tests.c6
-rw-r--r--test/core/iomgr/fd_posix_test.c8
-rw-r--r--test/core/iomgr/tcp_client_posix_test.c6
-rw-r--r--test/core/iomgr/tcp_server_posix_test.c2
-rw-r--r--test/core/util/test_config.h4
-rw-r--r--test/cpp/client/credentials_test.cc2
-rw-r--r--test/cpp/common/secure_auth_context_test.cc20
-rw-r--r--test/cpp/end2end/async_end2end_test.cc8
-rw-r--r--test/cpp/end2end/end2end_test.cc9
-rw-r--r--test/cpp/interop/client.cc7
-rw-r--r--test/cpp/interop/interop_client.cc28
-rw-r--r--test/cpp/interop/interop_client.h3
-rw-r--r--test/cpp/qps/qps_test.cc10
15 files changed, 74 insertions, 52 deletions
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index e7c113b36b..453376caec 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -222,6 +222,10 @@ void test_connect(const char *server_host, const char *client_host, int port,
drain_cq(cq);
grpc_completion_queue_destroy(cq);
+ 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);
gpr_free(details);
}
diff --git a/test/core/iomgr/alarm_test.c b/test/core/iomgr/alarm_test.c
index 362eb5fe63..55aa517529 100644
--- a/test/core/iomgr/alarm_test.c
+++ b/test/core/iomgr/alarm_test.c
@@ -41,6 +41,7 @@
#include <stdlib.h>
#include <string.h>
+#include <grpc/grpc.h>
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/sync.h>
@@ -100,7 +101,7 @@ static void test_grpc_alarm(void) {
alarm_arg arg2;
void *fdone;
- grpc_iomgr_init();
+ grpc_init();
arg.counter = 0;
arg.success = SUCCESS_NOT_SET;
@@ -113,7 +114,7 @@ static void test_grpc_alarm(void) {
gpr_event_init(&arg.fcb_arg);
grpc_alarm_init(&alarm, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100), alarm_cb, &arg,
- gpr_now(GPR_CLOCK_REALTIME));
+ gpr_now(GPR_CLOCK_MONOTONIC));
alarm_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
gpr_mu_lock(&arg.mu);
@@ -165,7 +166,7 @@ static void test_grpc_alarm(void) {
gpr_event_init(&arg2.fcb_arg);
grpc_alarm_init(&alarm_to_cancel, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(100),
- alarm_cb, &arg2, gpr_now(GPR_CLOCK_REALTIME));
+ alarm_cb, &arg2, gpr_now(GPR_CLOCK_MONOTONIC));
grpc_alarm_cancel(&alarm_to_cancel);
alarm_deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(1);
@@ -214,7 +215,7 @@ static void test_grpc_alarm(void) {
gpr_mu_destroy(&arg2.mu);
gpr_free(arg2.followup_closure);
- grpc_iomgr_shutdown();
+ grpc_shutdown();
}
int main(int argc, char **argv) {
diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c
index 0cfba5fac8..cb6adc58cf 100644
--- a/test/core/iomgr/endpoint_tests.c
+++ b/test/core/iomgr/endpoint_tests.c
@@ -254,7 +254,7 @@ static void read_and_write_test(grpc_endpoint_test_config config,
gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!state.read_done || !state.write_done) {
- GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_MONOTONIC), deadline) < 0);
grpc_pollset_work(g_pollset, deadline);
}
gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
@@ -350,14 +350,14 @@ static void shutdown_during_write_test(grpc_endpoint_test_config config,
deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(10);
gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!write_st.done) {
- GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_now(deadline.clock_type), deadline) < 0);
grpc_pollset_work(g_pollset, deadline);
}
gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
grpc_endpoint_destroy(write_st.ep);
gpr_mu_lock(GRPC_POLLSET_MU(g_pollset));
while (!read_st.done) {
- GPR_ASSERT(gpr_time_cmp(gpr_now(GPR_CLOCK_REALTIME), deadline) < 0);
+ GPR_ASSERT(gpr_time_cmp(gpr_now(deadline.clock_type), deadline) < 0);
grpc_pollset_work(g_pollset, deadline);
}
gpr_mu_unlock(GRPC_POLLSET_MU(g_pollset));
diff --git a/test/core/iomgr/fd_posix_test.c b/test/core/iomgr/fd_posix_test.c
index cd268661db..7d00c098cc 100644
--- a/test/core/iomgr/fd_posix_test.c
+++ b/test/core/iomgr/fd_posix_test.c
@@ -249,7 +249,7 @@ static int server_start(server *sv) {
static void server_wait_and_shutdown(server *sv) {
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (!sv->done) {
- grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME));
+ grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
@@ -356,7 +356,7 @@ static void client_start(client *cl, int port) {
static void client_wait_and_shutdown(client *cl) {
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (!cl->done) {
- grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME));
+ grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
}
@@ -445,7 +445,7 @@ static void test_grpc_fd_change(void) {
/* And now wait for it to run. */
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (a.cb_that_ran == NULL) {
- grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME));
+ grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
GPR_ASSERT(a.cb_that_ran == first_read_callback);
gpr_mu_unlock(GRPC_POLLSET_MU(&g_pollset));
@@ -463,7 +463,7 @@ static void test_grpc_fd_change(void) {
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (b.cb_that_ran == NULL) {
- grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_REALTIME));
+ grpc_pollset_work(&g_pollset, gpr_inf_future(GPR_CLOCK_MONOTONIC));
}
/* Except now we verify that second_read_callback ran instead */
GPR_ASSERT(b.cb_that_ran == second_read_callback);
diff --git a/test/core/iomgr/tcp_client_posix_test.c b/test/core/iomgr/tcp_client_posix_test.c
index 637886a738..38b7b5909d 100644
--- a/test/core/iomgr/tcp_client_posix_test.c
+++ b/test/core/iomgr/tcp_client_posix_test.c
@@ -196,13 +196,13 @@ void test_times_out(void) {
gpr_mu_lock(GRPC_POLLSET_MU(&g_pollset));
while (gpr_time_cmp(gpr_time_add(connect_deadline,
gpr_time_from_seconds(2, GPR_TIMESPAN)),
- gpr_now(GPR_CLOCK_REALTIME)) > 0) {
+ gpr_now(connect_deadline.clock_type)) > 0) {
int is_after_deadline =
- gpr_time_cmp(connect_deadline, gpr_now(GPR_CLOCK_REALTIME)) <= 0;
+ gpr_time_cmp(connect_deadline, gpr_now(GPR_CLOCK_MONOTONIC)) <= 0;
if (is_after_deadline &&
gpr_time_cmp(gpr_time_add(connect_deadline,
gpr_time_from_seconds(1, GPR_TIMESPAN)),
- gpr_now(GPR_CLOCK_REALTIME)) > 0) {
+ gpr_now(GPR_CLOCK_MONOTONIC)) > 0) {
/* allow some slack before insisting that things be done */
} else {
GPR_ASSERT(g_connections_complete ==
diff --git a/test/core/iomgr/tcp_server_posix_test.c b/test/core/iomgr/tcp_server_posix_test.c
index 83252a889b..f8d0fe8217 100644
--- a/test/core/iomgr/tcp_server_posix_test.c
+++ b/test/core/iomgr/tcp_server_posix_test.c
@@ -135,7 +135,7 @@ static void test_connect(int n) {
gpr_log(GPR_DEBUG, "wait");
while (g_nconnects == nconnects_before &&
- gpr_time_cmp(deadline, gpr_now(GPR_CLOCK_REALTIME)) > 0) {
+ gpr_time_cmp(deadline, gpr_now(deadline.clock_type)) > 0) {
grpc_pollset_work(&g_pollset, deadline);
}
gpr_log(GPR_DEBUG, "wait done");
diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h
index 063c797ce9..7028ade7b2 100644
--- a/test/core/util/test_config.h
+++ b/test/core/util/test_config.h
@@ -52,12 +52,12 @@ extern "C" {
(GRPC_TEST_SLOWDOWN_BUILD_FACTOR * GRPC_TEST_SLOWDOWN_MACHINE_FACTOR)
#define GRPC_TIMEOUT_SECONDS_TO_DEADLINE(x) \
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), \
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), \
gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e6 * (x), \
GPR_TIMESPAN))
#define GRPC_TIMEOUT_MILLIS_TO_DEADLINE(x) \
- gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), \
+ gpr_time_add(gpr_now(GPR_CLOCK_MONOTONIC), \
gpr_time_from_micros(GRPC_TEST_SLOWDOWN_FACTOR * 1e3 * (x), \
GPR_TIMESPAN))
diff --git a/test/cpp/client/credentials_test.cc b/test/cpp/client/credentials_test.cc
index ee94f455a4..bbf7705f0a 100644
--- a/test/cpp/client/credentials_test.cc
+++ b/test/cpp/client/credentials_test.cc
@@ -47,7 +47,7 @@ class CredentialsTest : public ::testing::Test {
TEST_F(CredentialsTest, InvalidServiceAccountCreds) {
std::shared_ptr<Credentials> bad1 = ServiceAccountCredentials("", "", 1);
- EXPECT_EQ(nullptr, bad1.get());
+ EXPECT_EQ(static_cast<Credentials *>(nullptr), bad1.get());
}
} // namespace testing
diff --git a/test/cpp/common/secure_auth_context_test.cc b/test/cpp/common/secure_auth_context_test.cc
index f18a04178e..d0243a5432 100644
--- a/test/cpp/common/secure_auth_context_test.cc
+++ b/test/cpp/common/secure_auth_context_test.cc
@@ -92,26 +92,6 @@ TEST_F(SecureAuthContextTest, Iterators) {
EXPECT_EQ("bar", p2.second);
++iter;
EXPECT_EQ(context.end(), iter);
- // Range-based for loop test.
- int i = 0;
- for (auto p : context) {
- switch (i++) {
- case 0:
- EXPECT_EQ("name", p.first);
- EXPECT_EQ("chapi", p.second);
- break;
- case 1:
- EXPECT_EQ("name", p.first);
- EXPECT_EQ("chapo", p.second);
- break;
- case 2:
- EXPECT_EQ("foo", p.first);
- EXPECT_EQ("bar", p.second);
- break;
- default:
- EXPECT_TRUE(0);
- }
- }
}
} // namespace
diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc
index 117d8bb9fa..b95bdf6b9b 100644
--- a/test/cpp/end2end/async_end2end_test.cc
+++ b/test/cpp/end2end/async_end2end_test.cc
@@ -415,7 +415,7 @@ TEST_F(AsyncEnd2endTest, ClientInitialMetadataRpc) {
auto client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second);
EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second);
- EXPECT_EQ(static_cast<size_t>(2), client_initial_metadata.size());
+ EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2));
send_response.set_message(recv_request.message());
response_writer.Finish(send_response, Status::OK, tag(3));
@@ -563,7 +563,7 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
auto client_initial_metadata = srv_ctx.client_metadata();
EXPECT_EQ(meta1.second, client_initial_metadata.find(meta1.first)->second);
EXPECT_EQ(meta2.second, client_initial_metadata.find(meta2.first)->second);
- EXPECT_EQ(static_cast<size_t>(2), client_initial_metadata.size());
+ EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2));
srv_ctx.AddInitialMetadata(meta3.first, meta3.second);
srv_ctx.AddInitialMetadata(meta4.first, meta4.second);
@@ -574,7 +574,7 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
auto server_initial_metadata = cli_ctx.GetServerInitialMetadata();
EXPECT_EQ(meta3.second, server_initial_metadata.find(meta3.first)->second);
EXPECT_EQ(meta4.second, server_initial_metadata.find(meta4.first)->second);
- EXPECT_EQ(static_cast<size_t>(2), server_initial_metadata.size());
+ EXPECT_GE(server_initial_metadata.size(), static_cast<size_t>(2));
send_response.set_message(recv_request.message());
srv_ctx.AddTrailingMetadata(meta5.first, meta5.second);
@@ -590,7 +590,7 @@ TEST_F(AsyncEnd2endTest, MetadataRpc) {
auto server_trailing_metadata = cli_ctx.GetServerTrailingMetadata();
EXPECT_EQ(meta5.second, server_trailing_metadata.find(meta5.first)->second);
EXPECT_EQ(meta6.second, server_trailing_metadata.find(meta6.first)->second);
- EXPECT_EQ(static_cast<size_t>(2), server_trailing_metadata.size());
+ EXPECT_GE(server_trailing_metadata.size(), static_cast<size_t>(2));
}
} // namespace
} // namespace testing
diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc
index 8b4424c735..20e4c4ed55 100644
--- a/test/cpp/end2end/end2end_test.cc
+++ b/test/cpp/end2end/end2end_test.cc
@@ -249,9 +249,10 @@ class End2endTest : public ::testing::Test {
void TearDown() GRPC_OVERRIDE { server_->Shutdown(); }
void ResetStub() {
- std::shared_ptr<ChannelInterface> channel =
- CreateChannel(server_address_.str(), FakeTransportSecurityCredentials(),
- ChannelArguments());
+ ChannelArguments args;
+ args.SetString(GRPC_ARG_SECONDARY_USER_AGENT_STRING, "end2end_test");
+ std::shared_ptr<ChannelInterface> channel = CreateChannel(
+ server_address_.str(), FakeTransportSecurityCredentials(), args);
stub_ = std::move(grpc::cpp::test::util::TestService::NewStub(channel));
}
@@ -508,7 +509,7 @@ TEST_F(End2endTest, DiffPackageServices) {
// rpc and stream should fail on bad credentials.
TEST_F(End2endTest, BadCredentials) {
std::shared_ptr<Credentials> bad_creds = ServiceAccountCredentials("", "", 1);
- EXPECT_EQ(nullptr, bad_creds.get());
+ EXPECT_EQ(static_cast<Credentials *>(nullptr), bad_creds.get());
std::shared_ptr<ChannelInterface> channel =
CreateChannel(server_address_.str(), bad_creds, ChannelArguments());
std::unique_ptr<grpc::cpp::test::util::TestService::Stub> stub(
diff --git a/test/cpp/interop/client.cc b/test/cpp/interop/client.cc
index 1f1e6c1306..d0393fafb2 100644
--- a/test/cpp/interop/client.cc
+++ b/test/cpp/interop/client.cc
@@ -69,6 +69,7 @@ DEFINE_string(test_case, "large_unary",
"compute_engine_creds: large_unary with compute engine auth; "
"jwt_token_creds: large_unary with JWT token auth; "
"oauth2_auth_token: raw oauth2 access token auth; "
+ "per_rpc_creds: raw oauth2 access token on a single rpc; "
"all : all of above.");
DEFINE_string(default_service_account, "",
"Email of GCE default service account");
@@ -117,6 +118,9 @@ int main(int argc, char** argv) {
} else if (FLAGS_test_case == "oauth2_auth_token") {
grpc::string json_key = GetServiceAccountJsonKey();
client.DoOauth2AuthToken(json_key, FLAGS_oauth_scope);
+ } else if (FLAGS_test_case == "per_rpc_creds") {
+ grpc::string json_key = GetServiceAccountJsonKey();
+ client.DoPerRpcCreds(json_key, FLAGS_oauth_scope);
} else if (FLAGS_test_case == "all") {
client.DoEmpty();
client.DoLargeUnary();
@@ -133,6 +137,7 @@ int main(int argc, char** argv) {
client.DoServiceAccountCreds(json_key, FLAGS_oauth_scope);
client.DoJwtTokenCreds(json_key);
client.DoOauth2AuthToken(json_key, FLAGS_oauth_scope);
+ client.DoPerRpcCreds(json_key, FLAGS_oauth_scope);
}
// compute_engine_creds only runs in GCE.
} else {
@@ -142,7 +147,7 @@ int main(int argc, char** argv) {
"large_unary|client_streaming|server_streaming|half_duplex|ping_pong|"
"cancel_after_begin|cancel_after_first_response|"
"timeout_on_sleeping_server|service_account_creds|compute_engine_creds|"
- "jwt_token_creds|oauth2_auth_token",
+ "jwt_token_creds|oauth2_auth_token|per_rpc_creds",
FLAGS_test_case.c_str());
ret = 1;
}
diff --git a/test/cpp/interop/interop_client.cc b/test/cpp/interop/interop_client.cc
index 4dcd8ad061..e5c0e4631f 100644
--- a/test/cpp/interop/interop_client.cc
+++ b/test/cpp/interop/interop_client.cc
@@ -41,8 +41,10 @@
#include <grpc/support/log.h>
#include <grpc++/channel_interface.h>
#include <grpc++/client_context.h>
+#include <grpc++/credentials.h>
#include <grpc++/status.h>
#include <grpc++/stream.h>
+#include "test/cpp/interop/client_helper.h"
#include "test/proto/test.grpc.pb.h"
#include "test/proto/empty.grpc.pb.h"
#include "test/proto/messages.grpc.pb.h"
@@ -166,6 +168,32 @@ void InteropClient::DoOauth2AuthToken(const grpc::string& username,
gpr_log(GPR_INFO, "Unary with oauth2 access token credentials done.");
}
+void InteropClient::DoPerRpcCreds(const grpc::string& username,
+ const grpc::string& oauth_scope) {
+ gpr_log(GPR_INFO,
+ "Sending a unary rpc with per-rpc raw oauth2 access token ...");
+ SimpleRequest request;
+ SimpleResponse response;
+ request.set_fill_username(true);
+ request.set_fill_oauth_scope(true);
+ std::unique_ptr<TestService::Stub> stub(TestService::NewStub(channel_));
+
+ ClientContext context;
+ grpc::string access_token = GetOauth2AccessToken();
+ std::shared_ptr<Credentials> creds = AccessTokenCredentials(access_token);
+ context.set_credentials(creds);
+
+ Status s = stub->UnaryCall(&context, request, &response);
+
+ AssertOkOrPrintErrorStatus(s);
+ GPR_ASSERT(!response.username().empty());
+ GPR_ASSERT(!response.oauth_scope().empty());
+ GPR_ASSERT(username.find(response.username()) != grpc::string::npos);
+ const char* oauth_scope_str = response.oauth_scope().c_str();
+ GPR_ASSERT(oauth_scope.find(oauth_scope_str) != grpc::string::npos);
+ gpr_log(GPR_INFO, "Unary with per-rpc oauth2 access token done.");
+}
+
void InteropClient::DoJwtTokenCreds(const grpc::string& username) {
gpr_log(GPR_INFO, "Sending a large unary rpc with JWT token credentials ...");
SimpleRequest request;
diff --git a/test/cpp/interop/interop_client.h b/test/cpp/interop/interop_client.h
index 67eecd9ccc..bf8188325e 100644
--- a/test/cpp/interop/interop_client.h
+++ b/test/cpp/interop/interop_client.h
@@ -71,6 +71,9 @@ class InteropClient {
// username is a string containing the user email
void DoOauth2AuthToken(const grpc::string& username,
const grpc::string& oauth_scope);
+ // username is a string containing the user email
+ void DoPerRpcCreds(const grpc::string& username,
+ const grpc::string& oauth_scope);
private:
void PerformLargeUnary(SimpleRequest* request, SimpleResponse* response);
diff --git a/test/cpp/qps/qps_test.cc b/test/cpp/qps/qps_test.cc
index 07b4834cc0..7b93443f7c 100644
--- a/test/cpp/qps/qps_test.cc
+++ b/test/cpp/qps/qps_test.cc
@@ -44,8 +44,8 @@
namespace grpc {
namespace testing {
-static const int WARMUP = 5;
-static const int BENCHMARK = 10;
+static const int WARMUP = 20;
+static const int BENCHMARK = 40;
static void RunQPS() {
gpr_log(GPR_INFO, "Running QPS test");
@@ -53,8 +53,8 @@ static void RunQPS() {
ClientConfig client_config;
client_config.set_client_type(ASYNC_CLIENT);
client_config.set_enable_ssl(false);
- client_config.set_outstanding_rpcs_per_channel(1000);
- client_config.set_client_channels(8);
+ client_config.set_outstanding_rpcs_per_channel(10);
+ client_config.set_client_channels(800);
client_config.set_payload_size(1);
client_config.set_async_client_threads(8);
client_config.set_rpc_type(UNARY);
@@ -62,7 +62,7 @@ static void RunQPS() {
ServerConfig server_config;
server_config.set_server_type(ASYNC_SERVER);
server_config.set_enable_ssl(false);
- server_config.set_threads(4);
+ server_config.set_threads(8);
const auto result =
RunScenario(client_config, 1, server_config, 1, WARMUP, BENCHMARK, -2);