datastore: use new rpcreplay method
Use the new Replayer.Connection method to establish a fake
connection on replay.
@@ -21,7 +21,6 @@ import (
"flag"
"fmt"
"log"
- "net"
"os"
"reflect"
"sort"
@@ -119,7 +118,7 @@ func initReplay() {
}
timeNow = ri.Time.In(time.Local)
- conn, err := replayConn(rep)
+ conn, err := rep.Connection()
if err != nil {
log.Fatal(err)
}
@@ -133,27 +132,6 @@ func initReplay() {
log.Printf("replaying from %s", replayFilename)
}
-func replayConn(rep *rpcreplay.Replayer) (*grpc.ClientConn, error) {
- // If we make a real connection we need creds from somewhere, and they
- // might not be available, for instance on Travis.
- // Replaying doesn't require a connection live at all, but we need
- // something to attach gRPC interceptors to.
- // So we start a local listener and connect to it, then close them down.
- // TODO(jba): build something like this into the replayer?
- l, err := net.Listen("tcp", "127.0.0.1:0")
- if err != nil {
- return nil, err
- }
- conn, err := grpc.Dial(l.Addr().String(),
- append([]grpc.DialOption{grpc.WithInsecure()}, rep.DialOptions()...)...)
- if err != nil {
- return nil, err
- }
- conn.Close()
- l.Close()
- return conn, nil
-}
-
func newClient(ctx context.Context, t *testing.T, dialOpts []grpc.DialOption) *Client {
if testing.Short() {
t.Skip("Integration tests skipped in short mode")
