public virtual void SetUp() { // Setup server for both protocols conf = new Configuration(); conf.SetInt(CommonConfigurationKeys.IpcMaximumDataLength, 1024); // Set RPC engine to protobuf RPC engine RPC.SetProtocolEngine(conf, typeof(TestProtoBufRpc.TestRpcService), typeof(ProtobufRpcEngine )); // Create server side implementation TestProtoBufRpc.PBServerImpl serverImpl = new TestProtoBufRpc.PBServerImpl(); BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.NewReflectiveBlockingService (serverImpl); // Get RPC server for server side implementation server = new RPC.Builder(conf).SetProtocol(typeof(TestProtoBufRpc.TestRpcService) ).SetInstance(service).SetBindAddress(Address).SetPort(Port).Build(); addr = NetUtils.GetConnectAddress(server); // now the second protocol TestProtoBufRpc.PBServer2Impl server2Impl = new TestProtoBufRpc.PBServer2Impl(); BlockingService service2 = TestRpcServiceProtos.TestProtobufRpc2Proto.NewReflectiveBlockingService (server2Impl); server.AddProtocol(RPC.RpcKind.RpcProtocolBuffer, typeof(TestProtoBufRpc.TestRpcService2 ), service2); server.Start(); }
public virtual void SetUp() { // create a server with two handlers server = new RPC.Builder(conf).SetProtocol(typeof(TestMultipleProtocolServer.Foo0 )).SetInstance(new TestMultipleProtocolServer.Foo0Impl(this)).SetBindAddress(Address ).SetPort(0).SetNumHandlers(2).SetVerbose(false).Build(); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestMultipleProtocolServer.Foo1 ), new TestMultipleProtocolServer.Foo1Impl(this)); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestMultipleProtocolServer.Bar ), new TestMultipleProtocolServer.BarImpl(this)); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestMultipleProtocolServer.Mixin ), new TestMultipleProtocolServer.BarImpl(this)); // Add Protobuf server // Create server side implementation TestProtoBufRpc.PBServerImpl pbServerImpl = new TestProtoBufRpc.PBServerImpl(); BlockingService service = TestRpcServiceProtos.TestProtobufRpcProto.NewReflectiveBlockingService (pbServerImpl); server.AddProtocol(RPC.RpcKind.RpcProtocolBuffer, typeof(TestProtoBufRpc.TestRpcService ), service); server.Start(); addr = NetUtils.GetConnectAddress(server); }
public virtual void TestVersion0ClientVersion1Server() { // old client vs new server // create a server with two handlers TestRPCCompatibility.TestImpl1 impl = new TestRPCCompatibility.TestImpl1(); server = new RPC.Builder(conf).SetProtocol(typeof(TestRPCCompatibility.TestProtocol1 )).SetInstance(impl).SetBindAddress(Address).SetPort(0).SetNumHandlers(2).SetVerbose (false).Build(); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestRPCCompatibility.TestProtocol0 ), impl); server.Start(); addr = NetUtils.GetConnectAddress(server); proxy = RPC.GetProtocolProxy <TestRPCCompatibility.TestProtocol0>(TestRPCCompatibility.TestProtocol0 .versionID, addr, conf); TestRPCCompatibility.TestProtocol0 proxy0 = (TestRPCCompatibility.TestProtocol0)proxy .GetProxy(); proxy0.Ping(); }
public virtual void TestVersion2ClientVersion2Server() { // equal version client and server // create a server with two handlers TestRPCCompatibility.TestImpl2 impl = new TestRPCCompatibility.TestImpl2(); server = new RPC.Builder(conf).SetProtocol(typeof(TestRPCCompatibility.TestProtocol2 )).SetInstance(impl).SetBindAddress(Address).SetPort(0).SetNumHandlers(2).SetVerbose (false).Build(); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestRPCCompatibility.TestProtocol0 ), impl); server.Start(); addr = NetUtils.GetConnectAddress(server); TestRPCCompatibility.Version2Client client = new TestRPCCompatibility.Version2Client (this); client.Ping(); Assert.Equal("hello", client.Echo("hello")); // now that echo(int) is supported by the server, echo(int) should return -3 Assert.Equal(-3, client.Echo(3)); }
public virtual void TestVersion2ClientVersion1Server() { // Compatible new client & old server // create a server with two handlers TestRPCCompatibility.TestImpl1 impl = new TestRPCCompatibility.TestImpl1(); server = new RPC.Builder(conf).SetProtocol(typeof(TestRPCCompatibility.TestProtocol1 )).SetInstance(impl).SetBindAddress(Address).SetPort(0).SetNumHandlers(2).SetVerbose (false).Build(); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestRPCCompatibility.TestProtocol0 ), impl); server.Start(); addr = NetUtils.GetConnectAddress(server); TestRPCCompatibility.Version2Client client = new TestRPCCompatibility.Version2Client (this); client.Ping(); Assert.Equal("hello", client.Echo("hello")); // echo(int) is not supported by server, so returning 3 // This verifies that echo(int) and echo(String)'s hash codes are different Assert.Equal(3, client.Echo(3)); }
public virtual void TestProtocolMetaInfoSSTranslatorPB() { TestRPCCompatibility.TestImpl1 impl = new TestRPCCompatibility.TestImpl1(); server = new RPC.Builder(conf).SetProtocol(typeof(TestRPCCompatibility.TestProtocol1 )).SetInstance(impl).SetBindAddress(Address).SetPort(0).SetNumHandlers(2).SetVerbose (false).Build(); server.AddProtocol(RPC.RpcKind.RpcWritable, typeof(TestRPCCompatibility.TestProtocol0 ), impl); server.Start(); ProtocolMetaInfoServerSideTranslatorPB xlator = new ProtocolMetaInfoServerSideTranslatorPB (server); ProtocolInfoProtos.GetProtocolSignatureResponseProto resp = xlator.GetProtocolSignature (null, CreateGetProtocolSigRequestProto(typeof(TestRPCCompatibility.TestProtocol1 ), RPC.RpcKind.RpcProtocolBuffer)); //No signatures should be found Assert.Equal(0, resp.GetProtocolSignatureCount()); resp = xlator.GetProtocolSignature(null, CreateGetProtocolSigRequestProto(typeof( TestRPCCompatibility.TestProtocol1), RPC.RpcKind.RpcWritable)); Assert.Equal(1, resp.GetProtocolSignatureCount()); ProtocolInfoProtos.ProtocolSignatureProto sig = resp.GetProtocolSignatureList()[0 ]; Assert.Equal(TestRPCCompatibility.TestProtocol1.versionID, sig .GetVersion()); bool found = false; int expected = ProtocolSignature.GetFingerprint(typeof(TestRPCCompatibility.TestProtocol1 ).GetMethod("echo", typeof(string))); foreach (int m in sig.GetMethodsList()) { if (expected == m) { found = true; break; } } Assert.True(found); }