|
25 | 25 | package clients |
26 | 26 |
|
27 | 27 | import ( |
28 | | - "context" |
29 | 28 | "fmt" |
| 29 | + "os" |
| 30 | + "testing" |
| 31 | + "time" |
| 32 | + |
30 | 33 | "github.com/sirupsen/logrus" |
31 | 34 | "github.com/vhive-serverless/loader/pkg/common" |
32 | 35 | "github.com/vhive-serverless/loader/pkg/config" |
33 | 36 | "github.com/vhive-serverless/loader/pkg/workload/standard" |
34 | | - helloworld "github.com/vhive-serverless/vSwarm/utils/protobuf/helloworld" |
35 | | - "google.golang.org/grpc" |
36 | | - "google.golang.org/grpc/reflection" |
37 | | - "net" |
38 | | - "os" |
39 | | - "testing" |
40 | | - "time" |
| 37 | + "github.com/vhive-serverless/loader/pkg/workload/vswarm" |
41 | 38 | ) |
42 | 39 |
|
43 | 40 | func createFakeLoaderConfiguration() *config.LoaderConfiguration { |
@@ -71,29 +68,6 @@ var testRuntimeSpecs = common.RuntimeSpecification{ |
71 | 68 | Memory: 128, |
72 | 69 | } |
73 | 70 |
|
74 | | -type vSwarmServer struct { |
75 | | - helloworld.UnimplementedGreeterServer |
76 | | -} |
77 | | - |
78 | | -func (s *vSwarmServer) SayHello(_ context.Context, req *helloworld.HelloRequest) (*helloworld.HelloReply, error) { |
79 | | - return &helloworld.HelloReply{ |
80 | | - Message: "Reply message", |
81 | | - }, nil |
82 | | -} |
83 | | - |
84 | | -func startVSwarmGRPCServer(serverAddress string, serverPort int) { |
85 | | - lis, err := net.Listen("tcp", fmt.Sprintf("%s:%d", serverAddress, serverPort)) |
86 | | - if err != nil { |
87 | | - logrus.Fatalf("failed to listen: %v", err) |
88 | | - } |
89 | | - |
90 | | - grpcServer := grpc.NewServer() |
91 | | - |
92 | | - reflection.Register(grpcServer) // gRPC Server Reflection is used by gRPC CLI |
93 | | - helloworld.RegisterGreeterServer(grpcServer, &vSwarmServer{}) |
94 | | - _ = grpcServer.Serve(lis) |
95 | | -} |
96 | | - |
97 | 71 | func TestGRPCClientWithServerUnreachable(t *testing.T) { |
98 | 72 | cfg := createFakeLoaderConfiguration() |
99 | 73 | cfg.EnableZipkinTracing = true |
@@ -161,7 +135,7 @@ func TestVSwarmClientWithServerReachable(t *testing.T) { |
161 | 135 | address, port := "localhost", 18081 |
162 | 136 | testFunction.Endpoint = fmt.Sprintf("%s:%d", address, port) |
163 | 137 |
|
164 | | - go startVSwarmGRPCServer(address, port) |
| 138 | + go vswarm.StartVSwarmGRPCServer(address, port) |
165 | 139 | time.Sleep(2 * time.Second) |
166 | 140 |
|
167 | 141 | cfgSwarm := createFakeVSwarmLoaderConfiguration() |
|
0 commit comments