test
This commit is contained in:
snoop 2017-06-21 11:50:14 +09:00
parent 973877454a
commit 76b6082f1c
2 changed files with 33 additions and 1 deletions

View File

@ -21,6 +21,8 @@ import (
"git.loafle.net/overflow/overflow_proxy_service/proxy/sensorItemMapping" "git.loafle.net/overflow/overflow_proxy_service/proxy/sensorItemMapping"
"log" "log"
"git.loafle.net/overflow/overflow_proxy_service/proxy/agent" "git.loafle.net/overflow/overflow_proxy_service/proxy/agent"
//"google.golang.org/grpc/metadata"
) )
var g_services map[string]interface{} var g_services map[string]interface{}
@ -62,7 +64,7 @@ type ServiceImpl struct {
func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.ServiceOutput, error) { func (s *ServiceImpl) ExecServices(c context.Context, in *pb.ServiceInput) (*pb.ServiceOutput, error) {
// Check Service Name // Check Service Name
serviceName, ok := g_services[in.ServiceName] serviceName, ok := g_services[in.ServiceName]
//metadata.FromContext(c)
log.Println("Service Name : " + in.ServiceName + " MethodName : " + in.MethodName) log.Println("Service Name : " + in.ServiceName + " MethodName : " + in.MethodName)
if !ok { if !ok {

View File

@ -12,6 +12,9 @@ import (
"bytes" "bytes"
"io/ioutil" "io/ioutil"
"log" "log"
"google.golang.org/grpc"
pb "git.loafle.net/overflow/overflow_api_service/grpc"
"golang.org/x/net/context"
) )
func startRpcServerTest() <- chan error{ func startRpcServerTest() <- chan error{
@ -87,3 +90,30 @@ func TestRpcServer(t *testing.T) {
os.Exit(1) os.Exit(1)
} }
} }
func TestRPC(t *testing.T) {
conn, err := grpc.Dial(":9090", grpc.WithInsecure());
if err != nil {
t.Log(err)
}
client := pb.NewOverflowGatewayClient(conn)
si := pb.ServiceInput{}
si.MethodName = "create"
si.ServiceName = "member"
si.Param = make(map[string]string)
si.Param["1"] = "2222"
so, err := client.ExecServices(context.Background(), &si)
t.Log(so.ResultStr)
}