Exemple #1
0
// the test here creates a fake server implementation, a fake client
// implementation, and runs the test suite against the setup.
func TestGRPCBinlogStreamer(t *testing.T) {
	// Listen on a random port
	listener, err := net.Listen("tcp", ":0")
	if err != nil {
		t.Fatalf("Cannot listen: %v", err)
	}
	host := listener.Addr().(*net.TCPAddr).IP.String()
	port := listener.Addr().(*net.TCPAddr).Port

	// Create a gRPC server and listen on the port
	server := grpc.NewServer()
	fakeUpdateStream := binlogplayertest.NewFakeBinlogStreamer(t)
	pbs.RegisterUpdateStreamServer(server, grpcbinlogstreamer.New(fakeUpdateStream))
	go server.Serve(listener)

	// Create a GRPC client to talk to the fake tablet
	c := &client{}

	// and send it to the test suite
	binlogplayertest.Run(t, c, topo.EndPoint{
		Host: host,
		NamedPortMap: map[string]int{
			"grpc": port,
		},
	}, fakeUpdateStream)
}
Exemple #2
0
func init() {
	binlog.RegisterUpdateStreamServices = append(binlog.RegisterUpdateStreamServices, func(updateStream proto.UpdateStream) {
		if servenv.GRPCCheckServiceMap("updatestream") {
			pbs.RegisterUpdateStreamServer(servenv.GRPCServer, New(updateStream))
		}
	})
}