Using a new method in protocols_flavor for types.

This commit is contained in:
Alain Jobart 2016-03-16 07:35:00 -07:00
Родитель b59a297ea9
Коммит 03cbfd20a2
4 изменённых файлов: 12 добавлений и 2 удалений

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

@ -50,6 +50,9 @@ class GoRpcProtocolsFlavor(protocols_flavor.ProtocolsFlavor):
def vtgate_python_protocol(self): def vtgate_python_protocol(self):
return 'gorpc' return 'gorpc'
def vtgate_python_types(self):
return 'mysql'
def client_error_exception_type(self): def client_error_exception_type(self):
return face.AbortionError return face.AbortionError

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

@ -45,6 +45,9 @@ class GRpcProtocolsFlavor(protocols_flavor.ProtocolsFlavor):
def vtgate_python_protocol(self): def vtgate_python_protocol(self):
return 'grpc' return 'grpc'
def vtgate_python_types(self):
return 'proto3'
def client_error_exception_type(self): def client_error_exception_type(self):
return face.AbortionError return face.AbortionError

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

@ -54,6 +54,10 @@ class ProtocolsFlavor(object):
"""The protocol to use to talk to vtgate with python clients.""" """The protocol to use to talk to vtgate with python clients."""
raise NotImplementedError('Not implemented in the base class') raise NotImplementedError('Not implemented in the base class')
def vtgate_python_types(self):
"""Returns either 'proto3' or 'mysql' for the enum types."""
raise NotImplementedError('Not implemented in the base class')
def client_error_exception_type(self): def client_error_exception_type(self):
"""The exception type the RPC client implementation returns for errors.""" """The exception type the RPC client implementation returns for errors."""
raise NotImplementedError('Not implemented in the base class') raise NotImplementedError('Not implemented in the base class')

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

@ -250,7 +250,7 @@ class TestVTGateFunctions(unittest.TestCase):
def setUp(self): def setUp(self):
self.master_tablet = shard_1_master self.master_tablet = shard_1_master
if protocols_flavor().vtgate_python_protocol() == 'grpc': if protocols_flavor().vtgate_python_types() == 'proto3':
self.int_type = 265 self.int_type = 265
self.string_type = 6165 self.string_type = 6165
else: else:
@ -334,7 +334,7 @@ class TestVTGateFunctions(unittest.TestCase):
# FIXME(alainjobart): the values encoded in these strings are not UTF-8, # FIXME(alainjobart): the values encoded in these strings are not UTF-8,
# causing the encoding to fail. Check with Sugu on what to do. # causing the encoding to fail. Check with Sugu on what to do.
# Maybe the keyrange should be HEX-encoded in the query to avoid the issue. # Maybe the keyrange should be HEX-encoded in the query to avoid the issue.
if protocols_flavor().vtgate_python_protocol() != 'grpc': if protocols_flavor().vtgate_python_types() != 'proto3':
result = self.execute_on_master( result = self.execute_on_master(
vtgate_conn, vtgate_conn,
"select * from vt_user where keyrange('', '\x80')", {}) "select * from vt_user where keyrange('', '\x80')", {})