Skip to content

Commit

Permalink
Merge pull request cockroachdb#58626 from otan-cockroach/backport20.2…
Browse files Browse the repository at this point in the history
…-58466

release-20.2: demo: fix --global option
  • Loading branch information
otan authored Jan 8, 2021
2 parents 36a7014 + 513d3c3 commit 38fe95d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pkg/cli/interactive_tests/test_demo_global.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

source [file join [file dirname $argv0] common.tcl]

# Set a larger timeout since we are going global.
set timeout 90

start_test "Check --global flag runs as expected"

# Start a demo with --global set
spawn $argv demo movr --global
spawn $argv demo movr --nodes 9 --global

# Ensure db is movr.
eexpect "movr>"
Expand Down
17 changes: 17 additions & 0 deletions pkg/rpc/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,23 @@ func (ctx *Context) grpcDialOptions(
dialOpts = append(dialOpts, grpc.WithStreamInterceptor(testingStreamInterceptor))
}
}
if ctx.Knobs.ArtificialLatencyMap != nil {
dialerFunc := func(ctx context.Context, target string) (net.Conn, error) {
dialer := net.Dialer{
LocalAddr: sourceAddr,
}
return dialer.DialContext(ctx, "tcp", target)
}
latency := ctx.Knobs.ArtificialLatencyMap[target]
log.VEventf(ctx.masterCtx, 1, "connecting to node %s with simulated latency %dms", target, latency)
dialer := artificialLatencyDialer{
dialerFunc: dialerFunc,
latencyMS: latency,
}
dialerFunc = dialer.dial
dialOpts = append(dialOpts, grpc.WithContextDialer(dialerFunc))
}

return dialOpts, nil
}

Expand Down

0 comments on commit 38fe95d

Please sign in to comment.