Skip to content

Commit

Permalink
Add support for receiving grpc_bind_adress on vttestserver
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriel Parreiras <[email protected]>
  • Loading branch information
gmpify committed Nov 14, 2024
1 parent 3499a77 commit bc26c47
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
5 changes: 5 additions & 0 deletions go/vt/servenv/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ func GRPCPort() int {
return gRPCPort
}

// GRPCPort returns the value of the `--grpc_bind_address` flag.
func GRPCBindAddress() string {
return gRPCBindAddress
}

// isGRPCEnabled returns true if gRPC server is set
func isGRPCEnabled() bool {
if gRPCPort != 0 {
Expand Down
1 change: 1 addition & 0 deletions go/vt/vttest/local_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ func (db *LocalCluster) JSONConfig() any {
config := map[string]any{
"bind_address": db.vt.BindAddress,
"port": db.vt.Port,
"grpc_bind_address": db.vt.BindAddressGprc,
"socket": db.mysql.UnixSocket(),
"vtcombo_mysql_port": db.Env.PortForProtocol("vtcombo_mysql_port", ""),
"mysql": db.Env.PortForProtocol("mysql", ""),
Expand Down
50 changes: 31 additions & 19 deletions go/vt/vttest/vtprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,17 @@ type HealthChecker func(addr string) bool
// It can be spawned manually or through one of the available
// helper methods.
type VtProcess struct {
Name string
Directory string
LogDirectory string
Binary string
ExtraArgs []string
Env []string
BindAddress string
Port int
PortGrpc int
HealthCheck HealthChecker
Name string
Directory string
LogDirectory string
Binary string
ExtraArgs []string
Env []string
BindAddress string
BindAddressGprc string
Port int
PortGrpc int
HealthCheck HealthChecker

proc *exec.Cmd
exit chan error
Expand Down Expand Up @@ -139,6 +140,11 @@ func (vtp *VtProcess) WaitStart() (err error) {
vtp.proc.Args = append(vtp.proc.Args, fmt.Sprintf("%d", vtp.PortGrpc))
}

if vtp.BindAddressGprc != "" {
vtp.proc.Args = append(vtp.proc.Args, "--grpc_bind_address")
vtp.proc.Args = append(vtp.proc.Args, vtp.BindAddressGprc)
}

vtp.proc.Args = append(vtp.proc.Args, vtp.ExtraArgs...)
vtp.proc.Env = append(vtp.proc.Env, os.Environ()...)
vtp.proc.Env = append(vtp.proc.Env, vtp.Env...)
Expand Down Expand Up @@ -199,16 +205,22 @@ func VtcomboProcess(environment Environment, args *Config, mysql MySQLManager) (
if args.VtComboBindAddress != "" {
vtcomboBindAddress = args.VtComboBindAddress
}
grpcBindAddress := "127.0.0.1"
if servenv.GRPCBindAddress() != "" {
grpcBindAddress = servenv.GRPCBindAddress()
}

vt := &VtProcess{
Name: "vtcombo",
Directory: environment.Directory(),
LogDirectory: environment.LogDirectory(),
Binary: environment.BinaryPath("vtcombo"),
BindAddress: vtcomboBindAddress,
Port: environment.PortForProtocol("vtcombo", ""),
PortGrpc: environment.PortForProtocol("vtcombo", "grpc"),
HealthCheck: environment.ProcessHealthCheck("vtcombo"),
Env: environment.EnvVars(),
Name: "vtcombo",
Directory: environment.Directory(),
LogDirectory: environment.LogDirectory(),
Binary: environment.BinaryPath("vtcombo"),
BindAddress: vtcomboBindAddress,
BindAddressGprc: grpcBindAddress,
Port: environment.PortForProtocol("vtcombo", ""),
PortGrpc: environment.PortForProtocol("vtcombo", "grpc"),
HealthCheck: environment.ProcessHealthCheck("vtcombo"),
Env: environment.EnvVars(),
}

user, pass := mysql.Auth()
Expand Down

0 comments on commit bc26c47

Please sign in to comment.