Skip to content

Commit

Permalink
datastore: use new rpcreplay method
Browse files Browse the repository at this point in the history
Use the new Replayer.Connection method to establish a fake
connection on replay.

Change-Id: I5327100a932327584531b20f9dc9217883a27b39
Reviewed-on: https://code-review.googlesource.com/c/37152
Reviewed-by: kokoro <[email protected]>
Reviewed-by: Eno Compton <[email protected]>
  • Loading branch information
jba committed Jan 8, 2019
1 parent fe66503 commit d015f18
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions datastore/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"flag"
"fmt"
"log"
"net"
"os"
"reflect"
"sort"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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")
Expand Down

0 comments on commit d015f18

Please sign in to comment.