mirror of
https://github.com/gmsec/gmsec.git
synced 2025-09-26 20:01:21 +08:00
fix: 导包路径不规范
feat: 调整server&client测试用例
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
/.idea
|
||||
*.iml
|
@@ -67,7 +67,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
proto "gmsec/rpc"
|
||||
proto "github.com/gmsec/gmsec/rpc"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gmsec/goplugins/plugin"
|
||||
@@ -113,7 +113,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
proto "gmsec/rpc"
|
||||
proto "github.com/gmsec/gmsec/rpc"
|
||||
|
||||
"github.com/gmsec/micro"
|
||||
)
|
||||
|
@@ -4,14 +4,15 @@ go 1.14
|
||||
|
||||
require (
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/gmsec/gmsec v0.0.0-20200516110103-d523c5e963e4
|
||||
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6
|
||||
github.com/gmsec/micro v0.0.0-20200512171333-e02c4bc357e0
|
||||
github.com/golang/protobuf v1.4.1
|
||||
github.com/golang/protobuf v1.4.1 // indirect
|
||||
github.com/xxjwxc/ginrpc v0.0.0-20200513173523-76244eb25d46
|
||||
github.com/xxjwxc/gowp v0.0.0-20200512110932-2a0c7dbb5cb8
|
||||
github.com/xxjwxc/public v0.0.0-20200512075732-ac398d0e55d0
|
||||
google.golang.org/grpc v1.29.1
|
||||
google.golang.org/protobuf v1.22.0
|
||||
google.golang.org/protobuf v1.22.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20200506231410-2ff61e1afc86
|
||||
)
|
||||
|
||||
|
@@ -30,6 +30,8 @@ github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
github.com/gmsec/gmsec v0.0.0-20200516110103-d523c5e963e4 h1:6d+g9n4END8hOTmWKZvYXaA7JI9vOfJY63kYnyZe7uI=
|
||||
github.com/gmsec/gmsec v0.0.0-20200516110103-d523c5e963e4/go.mod h1:BXI4GvIfCnQ7Izs7tKGoe/3m36XhgstvDwBXUqWwhe4=
|
||||
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6 h1:iCWzc/3Knyj7AEcDujZEKUoS4FL3hDENhk7B/eMQ+VU=
|
||||
github.com/gmsec/goplugins v0.0.0-20200512170621-7d971e4eeea6/go.mod h1:HumjBltVYT0U23Xv6+KAGQwK2q7jRsRVVDotOxQbOC4=
|
||||
github.com/gmsec/micro v0.0.0-20200512170207-8dff54fc0fa7 h1:j1h/OE4RN3mYUoLRpcLDd+przhFVmeHEbAq18xBqCNM=
|
||||
|
@@ -3,7 +3,7 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
proto "gmsec/rpc"
|
||||
proto "github.com/gmsec/gmsec/rpc"
|
||||
|
||||
"github.com/xxjwxc/public/tools"
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
proto "gmsec/rpc"
|
||||
proto "github.com/gmsec/gmsec/rpc"
|
||||
|
||||
"github.com/xxjwxc/public/dev"
|
||||
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
|
||||
"context"
|
||||
|
||||
proto "gmsec/rpc"
|
||||
proto "github.com/gmsec/gmsec/rpc"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gmsec/goplugins/plugin"
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
)
|
||||
|
||||
// TestMain test main
|
||||
func TestMain(t *testing.T) {
|
||||
func TestServer(m *testing.T) {
|
||||
// swagger
|
||||
myswagger.SetHost("https://localhost:8080")
|
||||
myswagger.SetBasePath("gmsec")
|
||||
@@ -53,35 +53,40 @@ func TestMain(t *testing.T) {
|
||||
plg, _ := plugin.Run(plugin.WithMicro(service),
|
||||
plugin.WithGin(router),
|
||||
plugin.WithAddr("localhost:8080"))
|
||||
|
||||
clientTest() // client test
|
||||
|
||||
time.Sleep(3 * time.Second)
|
||||
defer plg.Stop()
|
||||
// TestClient() // client test
|
||||
plg.Wait()
|
||||
/*time.Sleep(3 * time.Second)
|
||||
plg.Stop()
|
||||
fmt.Println("done")
|
||||
fmt.Println("done")*/
|
||||
}
|
||||
|
||||
func clientTest() {
|
||||
func TestClient(m *testing.T) {
|
||||
micro.SetClientServiceName(proto.GetHelloName(), "lp.srv.eg1") // set client group
|
||||
// first
|
||||
// service := micro.NewService(
|
||||
// micro.WithName("lp.srv.eg1"),
|
||||
// // micro.WithRegisterTTL(time.Second*30), //指定服务注册时间
|
||||
// micro.WithRegisterInterval(time.Second*15), //让服务在指定时间内重新注册
|
||||
// //micro.WithRegistryNameing(reg),
|
||||
// )
|
||||
go func() {
|
||||
wp := workpool.New(2) //设置最大线程数
|
||||
for i := 0; i < 20; i++ { //开启20个请求
|
||||
wp.Do(func() error {
|
||||
run()
|
||||
return nil
|
||||
})
|
||||
}
|
||||
micro.NewService(
|
||||
micro.WithName("lp.srv.eg1"),
|
||||
// micro.WithRegisterTTL(time.Second*30), //指定服务注册时间
|
||||
micro.WithRegisterInterval(time.Second*15), //让服务在指定时间内重新注册
|
||||
//micro.WithRegistryNameing(reg),
|
||||
)
|
||||
wp := workpool.New(2) //设置最大线程数
|
||||
for i := 0; i < 20; i++ { //开启20个请求
|
||||
wp.Do(func() error {
|
||||
say := proto.GetHelloClient()
|
||||
var request proto.HelloRequest
|
||||
request.Name = fmt.Sprintf("%v", rand.Intn(500))
|
||||
|
||||
wp.Wait()
|
||||
fmt.Println("clinet down")
|
||||
}()
|
||||
ctx := context.Background()
|
||||
resp, err := say.SayHello(ctx, &request)
|
||||
if err != nil {
|
||||
fmt.Println("==========err:", err)
|
||||
}
|
||||
fmt.Println(resp)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
wp.Wait()
|
||||
}
|
||||
|
||||
func run() {
|
||||
|
Reference in New Issue
Block a user