You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2021/06/15 06:31:36 UTC
[dubbo-go-samples] branch 3.0 updated: add triple integration test
(#139)
This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git
The following commit(s) were added to refs/heads/3.0 by this push:
new defcc32 add triple integration test (#139)
defcc32 is described below
commit defcc32d8341eced9c2c3f596ad7cd789501f67e
Author: Laurence <45...@users.noreply.github.com>
AuthorDate: Tue Jun 15 14:31:27 2021 +0800
add triple integration test (#139)
---
general/dubbo3/hessian2/go-client/cmd/client.go | 2 +-
general/dubbo3/hessian2/go-client/pkg/hello.go | 2 +-
general/dubbo3/hessian2/go-server/conf/client.yml | 2 +-
general/dubbo3/hessian2/go-server/pkg/greeter.go | 6 +-
.../go-server/tests/integration/main_test.go | 7 +-
.../tests/integration/userprovider_test.go | 7 +-
.../pb/dubbogo-grpc/protobuf/grpc/helloworld.proto | 78 ++--
.../dubbogo-grpc/server/dubbogo-server/cmd/env.sh | 2 -
.../dubbogo-server/docker/docker-compose.yml | 9 +
.../integration/grpc_test_proto/helloworld.pb.go | 411 +++++++++++++++++++++
.../dubbogo-server}/tests/integration/main_test.go | 36 +-
.../tests/integration/userprovider_test.go | 128 +++++++
.../go-server/docker/docker-compose.yml | 9 +
.../go-server/tests/integration/main_test.go | 36 +-
.../tests/integration/userprovider_test.go | 27 +-
start_integrate_test.sh | 12 +-
16 files changed, 655 insertions(+), 119 deletions(-)
diff --git a/general/dubbo3/hessian2/go-client/cmd/client.go b/general/dubbo3/hessian2/go-client/cmd/client.go
index f9d9671..10ab41f 100644
--- a/general/dubbo3/hessian2/go-client/cmd/client.go
+++ b/general/dubbo3/hessian2/go-client/cmd/client.go
@@ -56,7 +56,7 @@ func main() {
gxlog.CInfo("\n\n\nstart to test dubbo")
user := &pkg.User{}
- err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
+ err := userProvider.GetUser(context.TODO(), &pkg.User{Name: "laurence"} ,user)
if err != nil {
gxlog.CError("error: %v\n", err)
os.Exit(1)
diff --git a/general/dubbo3/hessian2/go-client/pkg/hello.go b/general/dubbo3/hessian2/go-client/pkg/hello.go
index 742fa65..092fe0e 100644
--- a/general/dubbo3/hessian2/go-client/pkg/hello.go
+++ b/general/dubbo3/hessian2/go-client/pkg/hello.go
@@ -28,7 +28,7 @@ type User struct {
}
type UserProvider struct {
- GetUser func(ctx context.Context, req []interface{}, rsp *User) error
+ GetUser func(ctx context.Context, req *User, rsp *User) error
}
func (u *UserProvider) Reference() string {
diff --git a/general/dubbo3/hessian2/go-server/conf/client.yml b/general/dubbo3/hessian2/go-server/conf/client.yml
index c9761ef..b9323fe 100644
--- a/general/dubbo3/hessian2/go-server/conf/client.yml
+++ b/general/dubbo3/hessian2/go-server/conf/client.yml
@@ -29,4 +29,4 @@ references:
registry: "demoZk"
protocol: "tri"
serialization: "hessian2"
- interface: "org.apache.dubbo.UserProvider"
\ No newline at end of file
+ interface: "com.apache.dubbo.sample.basic.IGreeter"
diff --git a/general/dubbo3/hessian2/go-server/pkg/greeter.go b/general/dubbo3/hessian2/go-server/pkg/greeter.go
index e6aef5e..c19f5ab 100644
--- a/general/dubbo3/hessian2/go-server/pkg/greeter.go
+++ b/general/dubbo3/hessian2/go-server/pkg/greeter.go
@@ -41,9 +41,9 @@ type User struct {
type UserProvider struct {
}
-func (u UserProvider) GetUser(ctx context.Context, req []interface{}) (*User, error) {
- gxlog.CInfo("req:%#v", req)
- rsp := User{"A001", "Alex Stocks", 18}
+func (u *UserProvider) GetUser(ctx context.Context, usr *User) (*User, error) {
+ gxlog.CInfo("req:%#v", usr)
+ rsp := User{"12345", "" + usr.Name, 18}
gxlog.CInfo("rsp:%#v", rsp)
return &rsp, nil
}
diff --git a/general/dubbo3/hessian2/go-server/tests/integration/main_test.go b/general/dubbo3/hessian2/go-server/tests/integration/main_test.go
index cfc20fb..76fbebb 100644
--- a/general/dubbo3/hessian2/go-server/tests/integration/main_test.go
+++ b/general/dubbo3/hessian2/go-server/tests/integration/main_test.go
@@ -54,17 +54,16 @@ type User struct {
ID string
Name string
Age int32
- Time time.Time
}
type UserProvider struct {
- GetUser func(ctx context.Context, req []interface{}, rsp *User) error
+ GetUser func(ctx context.Context, usr *User, rsp *User) error
}
func (u *UserProvider) Reference() string {
return "UserProvider"
}
-func (User) JavaClassName() string {
- return "org.apache.dubbo.User"
+func (u User) JavaClassName() string {
+ return "com.apache.dubbo.sample.basic.User"
}
diff --git a/general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go b/general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go
index 7183e64..639e911 100644
--- a/general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go
+++ b/general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go
@@ -30,10 +30,9 @@ import (
func TestGetUser(t *testing.T) {
user := &User{}
- err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
+ err := userProvider.GetUser(context.TODO(), &User{Name: "laurence"}, user)
assert.Nil(t, err)
- assert.Equal(t, "A001", user.ID)
- assert.Equal(t, "Alex Stocks", user.Name)
+ assert.Equal(t, "12345", user.ID)
+ assert.Equal(t, "laurence", user.Name)
assert.Equal(t, int32(18), user.Age)
- assert.NotNil(t, user.Time)
}
diff --git a/general/dubbo3/pb/dubbogo-grpc/protobuf/grpc/helloworld.proto b/general/dubbo3/pb/dubbogo-grpc/protobuf/grpc/helloworld.proto
index c29f4c5..dfec744 100644
--- a/general/dubbo3/pb/dubbogo-grpc/protobuf/grpc/helloworld.proto
+++ b/general/dubbo3/pb/dubbogo-grpc/protobuf/grpc/helloworld.proto
@@ -1,39 +1,39 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-syntax = "proto3";
-
-option go_package = "protobuf/dubbo3";
-package protobuf;
-
-// The greeting service definition.
-service Greeter {
- // Sends a greeting
- rpc SayHello (HelloRequest) returns (User) {}
- rpc SayHelloStream (stream HelloRequest) returns (stream User) {}
-}
-
-// The request message containing the user's name.
-message HelloRequest {
- string name = 1;
-}
-
-// The response message containing the greetings
-message User {
- string name = 1;
- string id = 2;
- int32 age = 3;
-}
\ No newline at end of file
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+syntax = "proto3";
+
+option go_package = "protobuf/dubbo3";
+package protobuf;
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello (HelloRequest) returns (User) {}
+ rpc SayHelloStream (stream HelloRequest) returns (stream User) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message User {
+ string name = 1;
+ string id = 2;
+ int32 age = 3;
+}
diff --git a/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/env.sh b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/env.sh
deleted file mode 100644
index d4a72c2..0000000
--- a/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/cmd/env.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-export CONF_PROVIDER_FILE_PATH="../conf/server.yml"
-export APP_LOG_CONF_FILE="../conf/log.yml"
\ No newline at end of file
diff --git a/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/docker/docker-compose.yml b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/docker/docker-compose.yml
new file mode 100644
index 0000000..8724179
--- /dev/null
+++ b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/docker/docker-compose.yml
@@ -0,0 +1,9 @@
+version: '3'
+
+services:
+ zookeeper:
+ image: zookeeper
+ ports:
+ - 2181:2181
+ restart: on-failure
+
diff --git a/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/grpc_test_proto/helloworld.pb.go b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/grpc_test_proto/helloworld.pb.go
new file mode 100644
index 0000000..2cae740
--- /dev/null
+++ b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/grpc_test_proto/helloworld.pb.go
@@ -0,0 +1,411 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: helloworld.proto
+
+package grpc_test_proto
+
+import (
+ context "context"
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+ math "math"
+)
+
+import (
+ "dubbo.apache.org/dubbo-go/v3/protocol"
+ dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
+ "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
+ tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
+ dubbo3 "github.com/dubbogo/triple/pkg/triple"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+// The request message containing the user's name.
+type HelloRequest struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *HelloRequest) Reset() { *m = HelloRequest{} }
+func (m *HelloRequest) String() string { return proto.CompactTextString(m) }
+func (*HelloRequest) ProtoMessage() {}
+func (*HelloRequest) Descriptor() ([]byte, []int) {
+ return fileDescriptor_17b8c58d586b62f2, []int{0}
+}
+
+func (m *HelloRequest) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_HelloRequest.Unmarshal(m, b)
+}
+func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic)
+}
+func (m *HelloRequest) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_HelloRequest.Merge(m, src)
+}
+func (m *HelloRequest) XXX_Size() int {
+ return xxx_messageInfo_HelloRequest.Size(m)
+}
+func (m *HelloRequest) XXX_DiscardUnknown() {
+ xxx_messageInfo_HelloRequest.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_HelloRequest proto.InternalMessageInfo
+
+func (m *HelloRequest) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+// The response message containing the greetings
+type User struct {
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
+ Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
+ Age int32 `protobuf:"varint,3,opt,name=age,proto3" json:"age,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *User) Reset() { *m = User{} }
+func (m *User) String() string { return proto.CompactTextString(m) }
+func (*User) ProtoMessage() {}
+func (*User) Descriptor() ([]byte, []int) {
+ return fileDescriptor_17b8c58d586b62f2, []int{1}
+}
+
+func (m *User) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_User.Unmarshal(m, b)
+}
+func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_User.Marshal(b, m, deterministic)
+}
+func (m *User) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_User.Merge(m, src)
+}
+func (m *User) XXX_Size() int {
+ return xxx_messageInfo_User.Size(m)
+}
+func (m *User) XXX_DiscardUnknown() {
+ xxx_messageInfo_User.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_User proto.InternalMessageInfo
+
+func (m *User) GetName() string {
+ if m != nil {
+ return m.Name
+ }
+ return ""
+}
+
+func (m *User) GetId() string {
+ if m != nil {
+ return m.Id
+ }
+ return ""
+}
+
+func (m *User) GetAge() int32 {
+ if m != nil {
+ return m.Age
+ }
+ return 0
+}
+
+
+var fileDescriptor_17b8c58d586b62f2 = []byte{
+ // 178 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9,
+ 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x00, 0x53,
+ 0x49, 0xa5, 0x69, 0x4a, 0x4a, 0x5c, 0x3c, 0x1e, 0x20, 0xd9, 0xa0, 0xd4, 0xc2, 0xd2, 0xd4, 0xe2,
+ 0x12, 0x21, 0x21, 0x2e, 0x96, 0xbc, 0xc4, 0xdc, 0x54, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20,
+ 0x30, 0x5b, 0xc9, 0x86, 0x8b, 0x25, 0xb4, 0x38, 0xb5, 0x08, 0x9b, 0x9c, 0x10, 0x1f, 0x17, 0x53,
+ 0x66, 0x8a, 0x04, 0x13, 0x58, 0x84, 0x29, 0x33, 0x45, 0x48, 0x80, 0x8b, 0x39, 0x31, 0x3d, 0x55,
+ 0x82, 0x59, 0x81, 0x51, 0x83, 0x35, 0x08, 0xc4, 0x34, 0xaa, 0xe7, 0x62, 0x77, 0x2f, 0x4a, 0x4d,
+ 0x2d, 0x49, 0x2d, 0x12, 0x32, 0xe1, 0xe2, 0x08, 0x4e, 0xac, 0x04, 0xdb, 0x27, 0x24, 0xa6, 0x07,
+ 0x73, 0x83, 0x1e, 0xb2, 0x03, 0xa4, 0xf8, 0x10, 0xe2, 0x20, 0x4b, 0x95, 0x18, 0x84, 0xec, 0xb8,
+ 0xf8, 0x60, 0xba, 0x82, 0x4b, 0x8a, 0x52, 0x13, 0x73, 0x89, 0xd7, 0xab, 0xc1, 0x68, 0xc0, 0x98,
+ 0xc4, 0x06, 0x16, 0x34, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0x98, 0x59, 0x9f, 0x6b, 0x07, 0x01,
+ 0x00, 0x00,
+}
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ context.Context
+var _ grpc.ClientConnInterface
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion6
+
+// GreeterClient is the client API for Greeter service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type GreeterClient interface {
+ // Sends a greeting
+ SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*User, error)
+ SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error)
+}
+
+type greeterClient struct {
+ cc grpc.ClientConnInterface
+}
+
+func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient {
+ return &greeterClient{cc}
+}
+
+func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*User, error) {
+ out := new(User)
+ err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+
+func (c *greeterClient) SayHelloStream(ctx context.Context, opts ...grpc.CallOption) (Greeter_SayHelloStreamClient, error) {
+ stream, err := c.cc.NewStream(ctx, &_Greeter_serviceDesc.Streams[0], "/protobuf.Greeter/SayHelloStream", opts...)
+ if err != nil {
+ return nil, err
+ }
+ x := &greeterSayHelloStreamClient{stream}
+ return x, nil
+}
+
+type Greeter_SayHelloStreamClient interface {
+ Send(*HelloRequest) error
+ Recv() (*User, error)
+ grpc.ClientStream
+}
+
+type greeterSayHelloStreamClient struct {
+ grpc.ClientStream
+}
+
+func (x *greeterSayHelloStreamClient) Send(m *HelloRequest) error {
+ return x.ClientStream.SendMsg(m)
+}
+
+func (x *greeterSayHelloStreamClient) Recv() (*User, error) {
+ m := new(User)
+ if err := x.ClientStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+// GreeterServer is the server API for Greeter service.
+type GreeterServer interface {
+ // Sends a greeting
+ SayHello(context.Context, *HelloRequest) (*User, error)
+ SayHelloStream(Greeter_SayHelloStreamServer) error
+}
+
+// UnimplementedGreeterServer can be embedded to have forward compatible implementations.
+type UnimplementedGreeterServer struct {
+}
+
+func (*UnimplementedGreeterServer) SayHello(ctx context.Context, req *HelloRequest) (*User, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
+}
+func (*UnimplementedGreeterServer) SayHelloStream(srv Greeter_SayHelloStreamServer) error {
+ return status.Errorf(codes.Unimplemented, "method SayHelloStream not implemented")
+}
+
+func RegisterGreeterServer(s *grpc.Server, srv GreeterServer) {
+ s.RegisterService(&_Greeter_serviceDesc, srv)
+}
+
+func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(HelloRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ if interceptor == nil {
+ return srv.(GreeterServer).SayHello(ctx, in)
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/protobuf.Greeter/SayHello",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _Greeter_SayHelloStream_Handler(srv interface{}, stream grpc.ServerStream) error {
+ return srv.(GreeterServer).SayHelloStream(&greeterSayHelloStreamServer{stream})
+}
+
+type Greeter_SayHelloStreamServer interface {
+ Send(*User) error
+ Recv() (*HelloRequest, error)
+ grpc.ServerStream
+}
+
+type greeterSayHelloStreamServer struct {
+ grpc.ServerStream
+}
+
+func (x *greeterSayHelloStreamServer) Send(m *User) error {
+ return x.ServerStream.SendMsg(m)
+}
+
+func (x *greeterSayHelloStreamServer) Recv() (*HelloRequest, error) {
+ m := new(HelloRequest)
+ if err := x.ServerStream.RecvMsg(m); err != nil {
+ return nil, err
+ }
+ return m, nil
+}
+
+var _Greeter_serviceDesc = grpc.ServiceDesc{
+ ServiceName: "protobuf.Greeter",
+ HandlerType: (*GreeterServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "SayHello",
+ Handler: _Greeter_SayHello_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "SayHelloStream",
+ Handler: _Greeter_SayHelloStream_Handler,
+ ServerStreams: true,
+ ClientStreams: true,
+ },
+ },
+ Metadata: "helloworld.proto",
+}
+
+type greeterDubbo3Client struct {
+ cc *dubbo3.TripleConn
+}
+
+func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient {
+ return &greeterDubbo3Client{cc}
+}
+func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opt ...grpc.CallOption) (*User, error) {
+ out := new(User)
+ interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)
+ err := c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
+ if err != nil {
+ return nil, err
+ }
+ return out, nil
+}
+func (c *greeterDubbo3Client) SayHelloStream(ctx context.Context, opt ...grpc.CallOption) (Greeter_SayHelloStreamClient, error) {
+ interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)
+ stream, err := c.cc.NewStream(ctx, "/"+interfaceKey+"/SayHelloStream", opt...)
+ if err != nil {
+ return nil, err
+ }
+ x := &greeterSayHelloStreamClient{stream}
+ return x, nil
+}
+
+// GreeterClientImpl is the client API for Greeter service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
+type GreeterClientImpl struct {
+ // Sends a greeting
+ SayHello func(ctx context.Context, in *HelloRequest, out *User) error
+ SayHelloStream func(ctx context.Context) (Greeter_SayHelloStreamClient, error)
+}
+
+func (c *GreeterClientImpl) Reference() string {
+ return "greeterImpl"
+}
+
+func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient {
+ return NewGreeterDubbo3Client(cc)
+}
+
+type GreeterProviderBase struct {
+ proxyImpl protocol.Invoker
+}
+
+func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) {
+ s.proxyImpl = impl
+}
+
+func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker {
+ return s.proxyImpl
+}
+
+func (c *GreeterProviderBase) Reference() string {
+ return "greeterImpl"
+}
+
+func _DUBBO_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(HelloRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ base := srv.(dgrpc.Dubbo3GrpcService)
+ args := []interface{}{}
+ args = append(args, in)
+ invo := invocation.NewRPCInvocation("SayHello", args, nil)
+ if interceptor == nil {
+ result := base.GetProxyImpl().Invoke(ctx, invo)
+ return result.Result(), result.Error()
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/protobuf.Greeter/SayHello",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ result := base.GetProxyImpl().Invoke(context.Background(), invo)
+ return result.Result(), result.Error()
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+func _DUBBO_Greeter_SayHelloStream_Handler(srv interface{}, stream grpc.ServerStream) error {
+ _, ok := srv.(dgrpc.Dubbo3GrpcService)
+ invo := invocation.NewRPCInvocation("SayHelloStream", nil, nil)
+ if !ok {
+ fmt.Println(invo)
+ }
+ return srv.(GreeterServer).SayHelloStream(&greeterSayHelloStreamServer{stream})
+}
+
+func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc {
+ return &grpc.ServiceDesc{
+ ServiceName: "protobuf.Greeter",
+ HandlerType: (*GreeterServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "SayHello",
+ Handler: _DUBBO_Greeter_SayHello_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{
+ {
+ StreamName: "SayHelloStream",
+ Handler: _DUBBO_Greeter_SayHelloStream_Handler,
+ ServerStreams: true,
+ ClientStreams: true,
+ },
+ },
+ Metadata: "helloworld.proto",
+ }
+}
diff --git a/general/dubbo3/hessian2/go-server/tests/integration/main_test.go b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/main_test.go
similarity index 72%
copy from general/dubbo3/hessian2/go-server/tests/integration/main_test.go
copy to general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/main_test.go
index cfc20fb..8d8a6e4 100644
--- a/general/dubbo3/hessian2/go-server/tests/integration/main_test.go
+++ b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/main_test.go
@@ -20,51 +20,35 @@
package integration
import (
- "context"
"os"
"testing"
"time"
)
-
import (
- hessian "github.com/apache/dubbo-go-hessian2"
+ "dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- "dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/inmemory"
- _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
+ _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
)
-var userProvider = new(UserProvider)
+import (
+ dubbo3pb "github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/protobuf/dubbo3"
+)
+
+
+var greeterProvider = new(dubbo3pb.GreeterClientImpl)
+
func TestMain(m *testing.M) {
- config.SetConsumerService(userProvider)
- hessian.RegisterPOJO(&User{})
+ config.SetConsumerService(greeterProvider)
config.Load()
time.Sleep(3 * time.Second)
os.Exit(m.Run())
}
-type User struct {
- ID string
- Name string
- Age int32
- Time time.Time
-}
-
-type UserProvider struct {
- GetUser func(ctx context.Context, req []interface{}, rsp *User) error
-}
-
-func (u *UserProvider) Reference() string {
- return "UserProvider"
-}
-
-func (User) JavaClassName() string {
- return "org.apache.dubbo.User"
-}
diff --git a/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/userprovider_test.go b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/userprovider_test.go
new file mode 100644
index 0000000..6da7d8e
--- /dev/null
+++ b/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/userprovider_test.go
@@ -0,0 +1,128 @@
+// +build integration
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+package integration
+
+import (
+ "context"
+ "testing"
+)
+import (
+ "github.com/stretchr/testify/assert"
+ "google.golang.org/grpc"
+ tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
+)
+import (
+ grpcpb "github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server/tests/integration/grpc_test_proto"
+ dubbo3pb "github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-grpc/protobuf/dubbo3"
+)
+
+func TestSayHello(t *testing.T) {
+ ctx := context.Background()
+ ctx = context.WithValue(ctx, tripleConstant.TripleCtxKey(tripleConstant.TripleRequestID), "triple-request-id-demo")
+ req := dubbo3pb.HelloRequest{
+ Name: "laurence",
+ }
+ user := dubbo3pb.User{}
+ err := greeterProvider.SayHello(ctx, &req, &user)
+ assert.Nil(t, err)
+ assert.Equal(t, "Hello laurence", user.Name)
+ assert.Equal(t, "12345", user.Id)
+ assert.Equal(t, int32(21), user.Age)
+}
+
+
+func TestStreamSayHello(t *testing.T){
+ ctx := context.Background()
+ ctx = context.WithValue(ctx, tripleConstant.TripleCtxKey(tripleConstant.TripleRequestID), "triple-request-id-demo")
+ req := dubbo3pb.HelloRequest{
+ Name: "laurence",
+ }
+
+ r, err := greeterProvider.SayHelloStream(ctx)
+ assert.Nil(t, err)
+
+ for i := 0; i < 3; i++ {
+ err := r.Send(&req)
+ assert.Nil(t, err)
+ }
+
+ rspUser := &dubbo3pb.User{}
+ err = r.RecvMsg(rspUser)
+ assert.Nil(t, err)
+ assert.Equal(t, "hello laurence",rspUser.Name)
+ assert.Equal(t, "123456789",rspUser.Id)
+ assert.Equal(t, int32(18),rspUser.Age)
+
+ err = r.RecvMsg(rspUser)
+ assert.Nil(t, err)
+ assert.Equal(t, "hello laurence",rspUser.Name)
+ assert.Equal(t, "123456789",rspUser.Id)
+ assert.Equal(t, int32(19),rspUser.Age)
+}
+
+func TestGRPCClientHello(t *testing.T) {
+ // Set up a connection to the client.
+ conn, err := grpc.Dial("127.0.0.1:20001", grpc.WithInsecure())
+ assert.Nil(t, err)
+ defer conn.Close()
+ c := grpcpb.NewGreeterClient(conn)
+
+ req := &grpcpb.HelloRequest{
+ Name: "laurence",
+ }
+ ctx := context.Background()
+ rsp, err := c.SayHello(ctx, req)
+ assert.Nil(t, err)
+ assert.Equal(t, "Hello laurence", rsp.Name)
+ assert.Equal(t, "12345", rsp.Id)
+ assert.Equal(t, int32(21), rsp.Age)
+}
+
+func TestGRPCClientStreamSayHello(t *testing.T){
+ conn, err := grpc.Dial("127.0.0.1:20001", grpc.WithInsecure())
+ assert.Nil(t, err)
+ defer conn.Close()
+ c := grpcpb.NewGreeterClient(conn)
+
+ req := &grpcpb.HelloRequest{
+ Name: "grpc laurence",
+ }
+ clientStream, err := c.SayHelloStream(context.Background())
+ assert.Nil(t, err)
+ for i := 0; i < 3; i++ {
+ err = clientStream.Send(req)
+ assert.Nil(t, err)
+ }
+
+ rspUser := &grpcpb.User{}
+ err = clientStream.RecvMsg(rspUser)
+ assert.Nil(t, err)
+ assert.Equal(t, "hello grpc laurence",rspUser.Name)
+ assert.Equal(t, "123456789",rspUser.Id)
+ assert.Equal(t, int32(18),rspUser.Age)
+
+ err = clientStream.RecvMsg(rspUser)
+ assert.Nil(t, err)
+ assert.Equal(t, "hello grpc laurence",rspUser.Name)
+ assert.Equal(t, "123456789",rspUser.Id)
+ assert.Equal(t, int32(19),rspUser.Age)
+}
+
+
diff --git a/general/dubbo3/pb/dubbogo-java/go-server/docker/docker-compose.yml b/general/dubbo3/pb/dubbogo-java/go-server/docker/docker-compose.yml
new file mode 100644
index 0000000..8724179
--- /dev/null
+++ b/general/dubbo3/pb/dubbogo-java/go-server/docker/docker-compose.yml
@@ -0,0 +1,9 @@
+version: '3'
+
+services:
+ zookeeper:
+ image: zookeeper
+ ports:
+ - 2181:2181
+ restart: on-failure
+
diff --git a/general/dubbo3/hessian2/go-server/tests/integration/main_test.go b/general/dubbo3/pb/dubbogo-java/go-server/tests/integration/main_test.go
similarity index 72%
copy from general/dubbo3/hessian2/go-server/tests/integration/main_test.go
copy to general/dubbo3/pb/dubbogo-java/go-server/tests/integration/main_test.go
index cfc20fb..ea0699a 100644
--- a/general/dubbo3/hessian2/go-server/tests/integration/main_test.go
+++ b/general/dubbo3/pb/dubbogo-java/go-server/tests/integration/main_test.go
@@ -20,51 +20,35 @@
package integration
import (
- "context"
"os"
"testing"
"time"
)
-
import (
- hessian "github.com/apache/dubbo-go-hessian2"
+ "dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/cluster/cluster_impl"
_ "dubbo.apache.org/dubbo-go/v3/cluster/loadbalance"
_ "dubbo.apache.org/dubbo-go/v3/common/proxy/proxy_factory"
- "dubbo.apache.org/dubbo-go/v3/config"
_ "dubbo.apache.org/dubbo-go/v3/filter/filter_impl"
_ "dubbo.apache.org/dubbo-go/v3/metadata/service/inmemory"
- _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
+ _ "dubbo.apache.org/dubbo-go/v3/protocol/dubbo"
_ "dubbo.apache.org/dubbo-go/v3/registry/protocol"
_ "dubbo.apache.org/dubbo-go/v3/registry/zookeeper"
)
-var userProvider = new(UserProvider)
+import (
+ dubbo3pb "github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-java/protobuf"
+)
+
+
+var greeterProvider = new(dubbo3pb.GreeterClientImpl)
+
func TestMain(m *testing.M) {
- config.SetConsumerService(userProvider)
- hessian.RegisterPOJO(&User{})
+ config.SetConsumerService(greeterProvider)
config.Load()
time.Sleep(3 * time.Second)
os.Exit(m.Run())
}
-type User struct {
- ID string
- Name string
- Age int32
- Time time.Time
-}
-
-type UserProvider struct {
- GetUser func(ctx context.Context, req []interface{}, rsp *User) error
-}
-
-func (u *UserProvider) Reference() string {
- return "UserProvider"
-}
-
-func (User) JavaClassName() string {
- return "org.apache.dubbo.User"
-}
diff --git a/general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go b/general/dubbo3/pb/dubbogo-java/go-server/tests/integration/userprovider_test.go
similarity index 66%
copy from general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go
copy to general/dubbo3/pb/dubbogo-java/go-server/tests/integration/userprovider_test.go
index 7183e64..9abdb3e 100644
--- a/general/dubbo3/hessian2/go-server/tests/integration/userprovider_test.go
+++ b/general/dubbo3/pb/dubbogo-java/go-server/tests/integration/userprovider_test.go
@@ -23,17 +23,28 @@ import (
"context"
"testing"
)
-
import (
"github.com/stretchr/testify/assert"
)
-func TestGetUser(t *testing.T) {
- user := &User{}
- err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user)
+import (
+ dubbo3pb "github.com/apache/dubbo-go-samples/general/dubbo3/pb/dubbogo-java/protobuf"
+)
+
+func TestSayHello(t *testing.T) {
+ req := &dubbo3pb.HelloRequest{
+ Name: "laurence",
+ }
+
+ reply := &dubbo3pb.User{}
+
+ ctx := context.Background()
+ ctx = context.WithValue(ctx, "tri-req-id", "test_value_XXXXXXXX")
+
+ err := greeterProvider.SayHello(ctx, req, reply)
+
assert.Nil(t, err)
- assert.Equal(t, "A001", user.ID)
- assert.Equal(t, "Alex Stocks", user.Name)
- assert.Equal(t, int32(18), user.Age)
- assert.NotNil(t, user.Time)
+ assert.Equal(t, "Hello laurence", reply.Name)
+ assert.Equal(t, "12345", reply.Id)
+ assert.Equal(t, int32(21), reply.Age)
}
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index a720d0d..66ebc0c 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -33,14 +33,18 @@ array+=("filter/custom/go-server")
array+=("filter/tpslimit/go-server")
array+=("filter/sentinel/go-server")
-# general
+# general-dubbo
array+=("general/dubbo/go-server")
-array+=("general/dubbo3/hessian2/go-server")
+# general-grpc
array+=("general/grpc/go-server")
-array+=("general/dubbo3/codec-extension/go-server")
-array+=("general/dubbo3/msgpack/go-server")
+# general-dubbo3(triple)
+array+=("general/dubbo3/pb/dubbogo-grpc/server/dubbogo-server")
+array+=("general/dubbo3/pb/dubbogo-java/go-server")
+array+=("general/dubbo3/hessian2/go-server")
+array+=("general/dubbo3/msgpack/go-server")
+array+=("general/dubbo3/codec-extension/go-server")
array+=("generic/go-server")