123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
-
- #include "hello_test.h"
- #include "servant/CommunicatorEpoll.h"
- #include "servant/ObjectProxy.h"
- #include "server/framework/DbHandle.h"
- #include "server/FrameworkServer.h"
- #include "QueryF.h"
- TEST_F(HelloTest, prxUpdate)
- {
- shared_ptr<Communicator> comm = getCommunicator();
- RpcServer rpc1Server;
- startServer(rpc1Server, RPC1_CONFIG());
- RpcServer rpc2Server;
- startServer(rpc2Server, RPC2_CONFIG());
- HelloPrx qPrx = comm->stringToProxy<HelloPrx>("TestApp.RpcServer.HelloObj@tcp -h 127.0.0.1 -p 9990:tcp -h 127.0.0.1 -p 9991");
- int ret;
- string out;
- ret = qPrx->testHello(0, _buffer, out);
- ASSERT_TRUE(ret == 0);
- ASSERT_TRUE(out == _buffer);
- set<EndpointInfo> active;
- active.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9992")));
- set<EndpointInfo> inactive;
- inactive.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9990")));
- inactive.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9991")));
- qPrx->tars_update_endpoints(active, inactive);
- stopServer(rpc1Server);
- stopServer(rpc2Server);
- RpcServer rpc3Server;
- startServer(rpc3Server, RPC3_CONFIG());
- ret = qPrx->testHello(0, _buffer, out);
- ASSERT_TRUE(ret == 0);
- ASSERT_TRUE(out == _buffer);
- stopServer(rpc3Server);
- }
- TEST_F(HelloTest, prxUpdateInCoroutine1)
- {
- shared_ptr<Communicator> comm = getCommunicator();
- RpcServer rpc1Server;
- startServer(rpc1Server, RPC1_CONFIG());
- RpcServer rpc2Server;
- startServer(rpc2Server, RPC2_CONFIG());
- int ret;
- string out;
- HelloPrx qPrx;
- funcInCoroutine([&](){
- qPrx = comm->stringToProxy<HelloPrx>("TestApp.RpcServer.HelloObj@tcp -h 127.0.0.1 -p 9990:tcp -h 127.0.0.1 -p 9991");
- ret = qPrx->testHello(0, _buffer, out);
- ASSERT_TRUE(ret == 0);
- ASSERT_TRUE(out == _buffer);
- });
- set<EndpointInfo> active;
- active.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9992")));
- set<EndpointInfo> inactive;
- inactive.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9990")));
- inactive.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9991")));
- qPrx->tars_update_endpoints(active, inactive);
- stopServer(rpc1Server);
- stopServer(rpc2Server);
- RpcServer rpc3Server;
- startServer(rpc3Server, RPC3_CONFIG());
- ret = qPrx->testHello(0, _buffer, out);
- ASSERT_TRUE(ret == 0);
- ASSERT_TRUE(out == _buffer);
- stopServer(rpc3Server);
- }
- TEST_F(HelloTest, prxUpdateInCoroutine2)
- {
- shared_ptr<Communicator> comm = getCommunicator();
- RpcServer rpc1Server;
- startServer(rpc1Server, RPC1_CONFIG());
- RpcServer rpc2Server;
- startServer(rpc2Server, RPC2_CONFIG());
- int ret;
- string out;
- HelloPrx qPrx;
- funcInCoroutine([&](){
- qPrx = comm->stringToProxy<HelloPrx>("TestApp.RpcServer.HelloObj@tcp -h 127.0.0.1 -p 9990:tcp -h 127.0.0.1 -p 9991");
- ret = qPrx->testHello(0, _buffer, out);
- ASSERT_TRUE(ret == 0);
- ASSERT_TRUE(out == _buffer);
- }, true);
- funcInCoroutine([&]()
- {
- set<EndpointInfo> active;
- active.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9992")));
- set<EndpointInfo> inactive;
- inactive.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9990")));
- inactive.insert(EndpointInfo(TC_Endpoint("tcp -h 127.0.0.1 -p 9991")));
- qPrx->tars_update_endpoints(active, inactive);
- }, true);
- stopServer(rpc1Server);
- stopServer(rpc2Server);
- RpcServer rpc3Server;
- startServer(rpc3Server, RPC3_CONFIG());
- ret = qPrx->testHello(0, _buffer, out);
- ASSERT_TRUE(ret == 0);
- ASSERT_TRUE(out == _buffer);
- stopServer(rpc3Server);
- }
|