Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release-20.2: demo: fix --global option #58626

Merged
merged 1 commit into from
Jan 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

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