Adding integration test support for grpc.

Only supported for vtctl client protocol for now.
This commit is contained in:
Alain Jobart 2015-02-27 14:24:04 -08:00
Родитель 69eaae951c
Коммит ed9a25393d
3 изменённых файлов: 35 добавлений и 3 удалений

Просмотреть файл

@ -44,8 +44,28 @@ class GoRpcProtocolsFlavor(ProtocolsFlavor):
def rpc_timeout_message(self):
return 'timeout waiting for'
class GRpcProtocolsFlavor(ProtocolsFlavor):
"""Overrides to use gRPC everywhere where it is supported.
If not supported yet, use GoRPC."""
def binlog_player_protocol_flags(self):
return ['-binlog_player_protocol', 'gorpc']
def vtctl_client_protocol(self):
return 'grpc'
def tablet_manager_protocol_flags(self):
return ['-tablet_manager_protocol', 'bson']
def tabletconn_protocol_flags(self):
return ['-tablet_protocol', 'gorpc']
def rpc_timeout_message(self):
return 'timeout waiting for'
__knows_protocols_flavor_map = {
'gorpc': GoRpcProtocolsFlavor,
'grpc': GRpcProtocolsFlavor,
}
__protocols_flavor = None

Просмотреть файл

@ -677,6 +677,8 @@ class Vtctld(object):
def __init__(self):
self.port = environment.reserve_ports(1)
if protocols_flavor().vtctl_client_protocol() == "grpc":
self.grpc_port = environment.reserve_ports(1)
def dbtopo(self):
data = json.load(urllib2.urlopen('http://localhost:%u/dbtopo?format=json' %
@ -700,6 +702,9 @@ class Vtctld(object):
] + \
environment.topo_server().flags() + \
protocols_flavor().tablet_manager_protocol_flags()
if protocols_flavor().vtctl_client_protocol() == "grpc":
args += ['-grpc_port', str(self.grpc_port),
'-service_map', 'grpc-vtctl']
stderr_fd = open(os.path.join(environment.tmproot, "vtctld.stderr"), "w")
self.proc = run_bg(args, stderr=stderr_fd)
@ -713,11 +718,15 @@ class Vtctld(object):
sleep_time=0.2)
# save the running instance so vtctl commands can be remote executed now
protocol = protocols_flavor().vtctl_client_protocol()
# temporary protocol override until python client support works
if protocol == "grpc":
protocol = "gorpc"
global vtctld, vtctld_connection
if not vtctld:
vtctld = self
vtctld_connection = vtctl_client.connect(
protocols_flavor().vtctl_client_protocol(), 'localhost:%u' % self.port, 30)
protocol, 'localhost:%u' % self.port, 30)
return self.proc
@ -732,10 +741,13 @@ class Vtctld(object):
else:
log_level='ERROR'
port = self.port
if protocols_flavor().vtctl_client_protocol() == 'grpc':
port = self.grpc_port
out, err = run(environment.binary_args('vtctlclient') +
['-vtctl_client_protocol',
protocols_flavor().vtctl_client_protocol(),
'-server', 'localhost:%u' % self.port,
'-server', 'localhost:%u' % port,
'-stderrthreshold', log_level] + args,
trap_output=True)
return out

Просмотреть файл

@ -142,7 +142,7 @@ class TestVtctld(unittest.TestCase):
def test_vtctl(self):
# standalone RPC client to vtctld
out, err = utils.run_vtctl(['ListAllTablets', 'test_nj'],
mode=utils.VTCTL_RPC)
mode=utils.VTCTL_VTCTLCLIENT)
self._check_all_tablets(out)
# vtctl querying the topology directly