TestHelper.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2019 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef TESTHELPER_H
20 #define TESTHELPER_H
21 
22 #import <XCTest/XCTest.h>
23 
24 #import <map>
25 #import <sstream>
26 
27 #import <grpc/support/time.h>
31 
32 #import "src/proto/grpc/testing/echo.grpc.pb.h"
33 
34 const char* const kServerFinishAfterNReads = "server_finish_after_n_reads";
35 const char* const kServerResponseStreamsToSend = "server_responses_to_send";
37 const char* const kDebugInfoTrailerKey = "debug-info-bin";
38 
40 void configureCronet(void);
41 bool CheckIsLocalhost(const std::string& addr);
42 
44  public:
47  static void Reset();
48  static int GetNumTimesRun();
49 
50  private:
51  static std::atomic<int> num_times_run_;
52  static std::atomic<int> num_times_run_reverse_;
53 };
54 
57  public:
59  grpc::experimental::ClientRpcInfo* info) override {
60  return new PhonyInterceptor();
61  }
62 };
63 
64 class TestServiceImpl : public grpc::testing::EchoTestService::Service {
65  public:
67  const grpc::testing::EchoRequest* request,
68  grpc::testing::EchoResponse* response);
72  grpc::testing::EchoResponse* response);
74  grpc::ServerContext* context, const grpc::testing::EchoRequest* request,
76 
79  grpc::ServerReaderWriter<grpc::testing::EchoResponse,
80  grpc::testing::EchoRequest>* stream);
81 };
82 
83 #endif /* TESTHELPER_H */
PhonyInterceptor::Reset
static void Reset()
grpc::string_ref
Definition: grpcpp/impl/codegen/string_ref.h:43
grpc::ServerWriter
Definition: include/grpcpp/impl/codegen/completion_queue.h:60
grpc::ServerContext
Definition: grpcpp/impl/codegen/server_context.h:566
kServerDefaultResponseStreamsToSend
const int kServerDefaultResponseStreamsToSend
Definition: TestHelper.h:36
TestServiceImpl::Echo
grpc::Status Echo(grpc::ServerContext *context, const grpc::testing::EchoRequest *request, grpc::testing::EchoResponse *response)
benchmark.request
request
Definition: benchmark.py:77
PhonyInterceptor
Definition: TestHelper.h:43
grpc::experimental::ClientInterceptorFactoryInterface
Definition: impl/codegen/client_interceptor.h:48
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
PhonyInterceptor::num_times_run_reverse_
static std::atomic< int > num_times_run_reverse_
Definition: TestHelper.h:52
grpc::ServerReaderWriter
Definition: grpcpp/impl/codegen/sync_stream.h:786
configureCronet
void configureCronet(void)
time.h
PhonyInterceptor::GetNumTimesRun
static int GetNumTimesRun()
config.h
grpc::experimental::ClientRpcInfo
Definition: impl/codegen/client_interceptor.h:68
kServerFinishAfterNReads
const char *const kServerFinishAfterNReads
Definition: TestHelper.h:34
PhonyInterceptor::PhonyInterceptor
PhonyInterceptor()
Definition: TestHelper.h:45
client_interceptor.h
PhonyInterceptor::Intercept
virtual void Intercept(grpc::experimental::InterceptorBatchMethods *methods)
ToString
std::string ToString(const grpc::string_ref &r)
Definition: string_ref_helper.cc:24
TestServiceImpl::RequestStream
grpc::Status RequestStream(grpc::ServerContext *context, grpc::ServerReader< grpc::testing::EchoRequest > *reader, grpc::testing::EchoResponse *response)
PhonyInterceptorFactory::CreateClientInterceptor
virtual grpc::experimental::Interceptor * CreateClientInterceptor(grpc::experimental::ClientRpcInfo *info) override
Definition: TestHelper.h:58
grpc::experimental::InterceptorBatchMethods
Definition: impl/codegen/interceptor.h:98
writer
void writer(void *n)
Definition: libuv/docs/code/locks/main.c:22
kServerResponseStreamsToSend
const char *const kServerResponseStreamsToSend
Definition: TestHelper.h:35
string_ref.h
TestServiceImpl::BidiStream
grpc::Status BidiStream(grpc::ServerContext *context, grpc::ServerReaderWriter< grpc::testing::EchoResponse, grpc::testing::EchoRequest > *stream)
kDebugInfoTrailerKey
const char *const kDebugInfoTrailerKey
Definition: TestHelper.h:37
grpc::experimental::Interceptor
Definition: impl/codegen/interceptor.h:221
fix_build_deps.r
r
Definition: fix_build_deps.py:491
asyncio_get_stats.response
response
Definition: asyncio_get_stats.py:28
grpc::ServerReader
Definition: include/grpcpp/impl/codegen/completion_queue.h:58
grpc::Status
Definition: include/grpcpp/impl/codegen/status.h:35
CheckIsLocalhost
bool CheckIsLocalhost(const std::string &addr)
PhonyInterceptor::num_times_run_
static std::atomic< int > num_times_run_
Definition: TestHelper.h:51
context
grpc::ClientContext context
Definition: istio_echo_server_lib.cc:61
TestServiceImpl
Definition: interop_server.cc:139
TestServiceImpl::ResponseStream
grpc::Status ResponseStream(grpc::ServerContext *context, const grpc::testing::EchoRequest *request, grpc::ServerWriter< grpc::testing::EchoResponse > *writer)
PhonyInterceptorFactory
Definition: TestHelper.h:55
addr
struct sockaddr_in addr
Definition: libuv/docs/code/tcp-echo-server/main.c:10
reader
void reader(void *n)
Definition: libuv/docs/code/locks/main.c:8
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:34