This is an automated email from the ASF dual-hosted git repository.

laurence pushed a commit to branch config-enhance
in repository https://gitbox.apache.org/repos/asf/dubbo-go-samples.git


The following commit(s) were added to refs/heads/config-enhance by this push:
     new 83949a5  feat: add msgpack intrgrate test (#246)
83949a5 is described below

commit 83949a53c77a7a5ca3207aa85fa33b24b31e38b7
Author: 氕氘氚 <[email protected]>
AuthorDate: Mon Sep 13 17:15:20 2021 +0800

    feat: add msgpack intrgrate test (#246)
    
    * feat: add msgpack intrgrate test
    
    * fix: reference error
    
    * fix: replace id and name
    
    * style: fmt code
    
    * feat: del reference & add run xml
---
 .run/triple-msgpack-client.run.xml                 | 14 ++++++++
 .run/triple-msgpack-server.run.xml                 | 14 ++++++++
 .../triple/msgpack/tests/integration/main_test.go  | 31 ++++------------
 .../msgpack/tests/integration/userprovider_test.go | 41 +++++-----------------
 rpc/triple/msgpack/go-client/cmd/client.go         |  4 ---
 rpc/triple/msgpack/go-client/conf/dubbogo.yml      | 14 ++++----
 rpc/triple/msgpack/go-server/cmd/server.go         |  8 ++---
 rpc/triple/msgpack/go-server/conf/dubbogo.yml      | 16 ++++-----
 start_integrate_test.sh                            |  1 +
 9 files changed, 61 insertions(+), 82 deletions(-)

diff --git a/.run/triple-msgpack-client.run.xml 
b/.run/triple-msgpack-client.run.xml
new file mode 100644
index 0000000..eee0b2f
--- /dev/null
+++ b/.run/triple-msgpack-client.run.xml
@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="triple-msgpack-client" 
type="GoApplicationRunConfiguration" factoryName="Go Application">
+    <module name="dubbo-go-samples" />
+    <working_directory value="$PROJECT_DIR$" />
+    <envs>
+      <env name="DUBBO_GO_CONFIG_PATH" 
value="$PROJECT_DIR$/rpc/triple/msgpack/go-client/conf/dubbogo.yml" />
+    </envs>
+    <kind value="PACKAGE" />
+    <package 
value="github.com/apache/dubbo-go-samples/rpc/triple/msgpack/go-client/cmd" />
+    <directory value="$PROJECT_DIR$" />
+    <filePath value="$PROJECT_DIR$/rpc/triple/msgpack/go-client/cmd/client.go" 
/>
+    <method v="2" />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/.run/triple-msgpack-server.run.xml 
b/.run/triple-msgpack-server.run.xml
new file mode 100644
index 0000000..69629e2
--- /dev/null
+++ b/.run/triple-msgpack-server.run.xml
@@ -0,0 +1,14 @@
+<component name="ProjectRunConfigurationManager">
+  <configuration default="false" name="triple-msgpack-server" 
type="GoApplicationRunConfiguration" factoryName="Go Application">
+    <module name="dubbo-go-samples" />
+    <working_directory value="$PROJECT_DIR$" />
+    <envs>
+      <env name="DUBBO_GO_CONFIG_PATH" 
value="$PROJECT_DIR$/rpc/triple/msgpack/go-server/conf/dubbogo.yml" />
+    </envs>
+    <kind value="PACKAGE" />
+    <package 
value="github.com/apache/dubbo-go-samples/rpc/triple/msgpack/go-server/cmd" />
+    <directory value="$PROJECT_DIR$" />
+    <filePath value="$PROJECT_DIR$/rpc/triple/msgpack/go-server/cmd/server.go" 
/>
+    <method v="2" />
+  </configuration>
+</component>
\ No newline at end of file
diff --git a/rpc/triple/msgpack/go-client/cmd/client.go 
b/integrate_test/rpc/triple/msgpack/tests/integration/main_test.go
similarity index 71%
copy from rpc/triple/msgpack/go-client/cmd/client.go
copy to integrate_test/rpc/triple/msgpack/tests/integration/main_test.go
index 3320d6a..4c93a7b 100644
--- a/rpc/triple/msgpack/go-client/cmd/client.go
+++ b/integrate_test/rpc/triple/msgpack/tests/integration/main_test.go
@@ -15,50 +15,33 @@
  * limitations under the License.
  */
 
-package main
+package integration
 
 import (
        "context"
        "os"
+       "testing"
        "time"
 )
 
 import (
        "dubbo.apache.org/dubbo-go/v3/config"
        _ "dubbo.apache.org/dubbo-go/v3/imports"
-
-       gxlog "github.com/dubbogo/gost/log"
 )
 
 import (
        "github.com/apache/dubbo-go-samples/api"
 )
 
-type UserProvider struct {
-       GetUser func(ctx context.Context, req *api.User) (rsp *api.User, err 
error)
-}
-
-func (u *UserProvider) Reference() string {
-       return "greeterImpl"
-}
-
 var userProvider = new(UserProvider)
 
-func init() {
+func TestMain(m *testing.M) {
        config.SetConsumerService(userProvider)
-}
-
-// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to 
"conf/client.yml" before run
-func main() {
        config.Load()
        time.Sleep(3 * time.Second)
+       os.Exit(m.Run())
+}
 
-       gxlog.CInfo("\n\n\nstart to test dubbo")
-       user, err := userProvider.GetUser(context.TODO(), &api.User{Name: 
"laurence"})
-       if err != nil {
-               gxlog.CError("error: %v\n", err)
-               os.Exit(1)
-               return
-       }
-       gxlog.CInfo("response result: %v\n", user)
+type UserProvider struct {
+       GetUser func(ctx context.Context, req *api.User) (rsp *api.User, err 
error)
 }
diff --git a/rpc/triple/msgpack/go-client/cmd/client.go 
b/integrate_test/rpc/triple/msgpack/tests/integration/userprovider_test.go
similarity index 56%
copy from rpc/triple/msgpack/go-client/cmd/client.go
copy to integrate_test/rpc/triple/msgpack/tests/integration/userprovider_test.go
index 3320d6a..0db7080 100644
--- a/rpc/triple/msgpack/go-client/cmd/client.go
+++ b/integrate_test/rpc/triple/msgpack/tests/integration/userprovider_test.go
@@ -15,50 +15,25 @@
  * limitations under the License.
  */
 
-package main
+package integration
 
 import (
        "context"
-       "os"
-       "time"
+       "testing"
 )
 
 import (
-       "dubbo.apache.org/dubbo-go/v3/config"
-       _ "dubbo.apache.org/dubbo-go/v3/imports"
-
-       gxlog "github.com/dubbogo/gost/log"
+       "github.com/stretchr/testify/assert"
 )
 
 import (
        "github.com/apache/dubbo-go-samples/api"
 )
 
-type UserProvider struct {
-       GetUser func(ctx context.Context, req *api.User) (rsp *api.User, err 
error)
-}
-
-func (u *UserProvider) Reference() string {
-       return "greeterImpl"
-}
-
-var userProvider = new(UserProvider)
-
-func init() {
-       config.SetConsumerService(userProvider)
-}
-
-// need to setup environment variable "CONF_CONSUMER_FILE_PATH" to 
"conf/client.yml" before run
-func main() {
-       config.Load()
-       time.Sleep(3 * time.Second)
-
-       gxlog.CInfo("\n\n\nstart to test dubbo")
+func TestGetUser(t *testing.T) {
        user, err := userProvider.GetUser(context.TODO(), &api.User{Name: 
"laurence"})
-       if err != nil {
-               gxlog.CError("error: %v\n", err)
-               os.Exit(1)
-               return
-       }
-       gxlog.CInfo("response result: %v\n", user)
+       assert.Nil(t, err)
+       assert.Equal(t, "12345", user.Id)
+       assert.Equal(t, "Hello laurence", user.Name)
+       assert.Equal(t, int32(18), user.Age)
 }
diff --git a/rpc/triple/msgpack/go-client/cmd/client.go 
b/rpc/triple/msgpack/go-client/cmd/client.go
index 3320d6a..a563605 100644
--- a/rpc/triple/msgpack/go-client/cmd/client.go
+++ b/rpc/triple/msgpack/go-client/cmd/client.go
@@ -38,10 +38,6 @@ type UserProvider struct {
        GetUser func(ctx context.Context, req *api.User) (rsp *api.User, err 
error)
 }
 
-func (u *UserProvider) Reference() string {
-       return "greeterImpl"
-}
-
 var userProvider = new(UserProvider)
 
 func init() {
diff --git a/rpc/triple/msgpack/go-client/conf/dubbogo.yml 
b/rpc/triple/msgpack/go-client/conf/dubbogo.yml
index b33f18c..71ac0fd 100644
--- a/rpc/triple/msgpack/go-client/conf/dubbogo.yml
+++ b/rpc/triple/msgpack/go-client/conf/dubbogo.yml
@@ -1,14 +1,14 @@
 dubbo:
   registries:
     "demoZK":
-      protocol: "zookeeper"
-      timeout: "3s"
-      address: "127.0.0.1:2181"
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
   consumer:
     registry:
       - demoZK
     references:
-      "greeterImpl":
-        protocol: "tri"
-        serialization: "msgpack"
-        interface: "com.apache.dubbo.sample.basic.IGreeter" # must be 
compatible with grpc or dubbo-java
\ No newline at end of file
+      UserProvider:
+        protocol: tri
+        serialization: msgpack
+        interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible 
with grpc or dubbo-java
\ No newline at end of file
diff --git a/rpc/triple/msgpack/go-server/cmd/server.go 
b/rpc/triple/msgpack/go-server/cmd/server.go
index 1fa8b8d..1bbbe6b 100644
--- a/rpc/triple/msgpack/go-server/cmd/server.go
+++ b/rpc/triple/msgpack/go-server/cmd/server.go
@@ -44,18 +44,14 @@ type UserProvider struct {
 func (u UserProvider) GetUser(ctx context.Context, user *api.User) (*api.User, 
error) {
        gxlog.CInfo("req:%#v", user)
        rsp := api.User{
-               Name: "12345",
-               Id:   "Hello " + user.Name,
+               Id:   "12345",
+               Name: "Hello " + user.Name,
                Age:  18,
        }
        gxlog.CInfo("rsp:%#v", rsp)
        return &rsp, nil
 }
 
-func (u UserProvider) Reference() string {
-       return "greeterImpl"
-}
-
 var (
        survivalTimeout = int(3 * time.Second)
 )
diff --git a/rpc/triple/msgpack/go-server/conf/dubbogo.yml 
b/rpc/triple/msgpack/go-server/conf/dubbogo.yml
index 0b208b4..a3d772e 100644
--- a/rpc/triple/msgpack/go-server/conf/dubbogo.yml
+++ b/rpc/triple/msgpack/go-server/conf/dubbogo.yml
@@ -1,18 +1,18 @@
 dubbo:
   registries:
     "demoZK":
-      protocol: "zookeeper"
-      timeout: "3s"
-      address: "127.0.0.1:2181"
+      protocol: zookeeper
+      timeout: 3s
+      address: 127.0.0.1:2181
   protocols:
     "triple":
-      name: "tri"
+      name: tri
       port: 20000
   provider:
     registry:
       - demoZK
     services:
-      "greeterImpl":
-        protocol: "triple"
-        serialization: "msgpack"
-        interface: "com.apache.dubbo.sample.basic.IGreeter" # must be 
compatible with grpc or dubbo-java
\ No newline at end of file
+      UserProvider:
+        protocol: triple
+        serialization: msgpack
+        interface: com.apache.dubbo.sample.basic.IGreeter # must be compatible 
with grpc or dubbo-java
\ No newline at end of file
diff --git a/start_integrate_test.sh b/start_integrate_test.sh
index f418828..91de649 100755
--- a/start_integrate_test.sh
+++ b/start_integrate_test.sh
@@ -109,6 +109,7 @@ array+=("generic/default")
 array+=("rpc/dubbo")
 array+=("rpc/triple/codec-extension")
 array+=("rpc/triple/hessian2")
+array+=("rpc/triple/msgpack")
 array+=("rpc/triple/pb/dubbogo-grpc")
 array+=("rpc/grpc")
 

Reply via email to