Pull cleanup: minor changes after merging pull request #172

This commit is contained in:
Srivats P 2015-12-24 14:16:35 +05:30
parent 1e268080c2
commit 414d89860d
2 changed files with 16 additions and 10 deletions

View File

@ -80,6 +80,8 @@ class OstinatoRpcChannel(RpcChannel):
try: try:
self.log.info('invoking RPC %s(%s): %s', method.name, self.log.info('invoking RPC %s(%s): %s', method.name,
type(request).__name__, response_class.__name__) type(request).__name__, response_class.__name__)
if not request.IsInitialized():
raise RpcError('missing required fields in request')
self.log.debug('serializing request arg %s', request) self.log.debug('serializing request arg %s', request)
req = request.SerializeToString() req = request.SerializeToString()
hdr = struct.pack('>HHI', MSG_TYPE_REQUEST, method.index, len(req)) hdr = struct.pack('>HHI', MSG_TYPE_REQUEST, method.index, len(req))

View File

@ -116,6 +116,7 @@ try:
passed = False passed = False
suite.test_begin('connectFailsForIncompatibleVersion') suite.test_begin('connectFailsForIncompatibleVersion')
try: try:
orig_version = core.__version__
core.__version__ = '0.1.1' core.__version__ = '0.1.1'
drone.connect() drone.connect()
except RpcError as e: except RpcError as e:
@ -125,7 +126,7 @@ try:
else: else:
raise raise
finally: finally:
core.__version__ = None core.__version__ = orig_version
suite.test_end(passed) suite.test_end(passed)
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
@ -134,6 +135,7 @@ try:
passed = False passed = False
suite.test_begin('checkVersionFailsForInvalidClientVersion') suite.test_begin('checkVersionFailsForInvalidClientVersion')
try: try:
orig_version = core.__version__
core.__version__ = '0-1-1' core.__version__ = '0-1-1'
drone.connect() drone.connect()
except RpcError as e: except RpcError as e:
@ -142,7 +144,7 @@ try:
else: else:
raise raise
finally: finally:
core.__version__ = None core.__version__ = orig_version
suite.test_end(passed) suite.test_end(passed)
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
@ -154,6 +156,7 @@ try:
passed = False passed = False
suite.test_begin('checkVersionReturnsIncompatForDifferentMajorVersion') suite.test_begin('checkVersionReturnsIncompatForDifferentMajorVersion')
try: try:
orig_version = core.__version__
core.__version__ = (str(int(drone_version[0])+1) core.__version__ = (str(int(drone_version[0])+1)
+ '.' + drone_version[1]) + '.' + drone_version[1])
drone.connect() drone.connect()
@ -164,7 +167,7 @@ try:
else: else:
raise raise
finally: finally:
core.__version__ = None core.__version__ = orig_version
suite.test_end(passed) suite.test_end(passed)
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
@ -176,6 +179,7 @@ try:
passed = False passed = False
suite.test_begin('checkVersionReturnsIncompatForDifferentMinorVersion') suite.test_begin('checkVersionReturnsIncompatForDifferentMinorVersion')
try: try:
orig_version = core.__version__
core.__version__ = (drone_version[0] core.__version__ = (drone_version[0]
+ '.' + str(int(drone_version[1])+1)) + '.' + str(int(drone_version[1])+1))
drone.connect() drone.connect()
@ -186,7 +190,7 @@ try:
else: else:
raise raise
finally: finally:
core.__version__ = None core.__version__ = orig_version
suite.test_end(passed) suite.test_end(passed)
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
@ -197,6 +201,7 @@ try:
passed = False passed = False
suite.test_begin('checkVersionReturnsCompatForDifferentRevisionVersion') suite.test_begin('checkVersionReturnsCompatForDifferentRevisionVersion')
try: try:
orig_version = core.__version__
core.__version__ = (drone_version[0] core.__version__ = (drone_version[0]
+ '.' + drone_version[1] + '.' + drone_version[1]
+ '.' + '999') + '.' + '999')
@ -205,7 +210,8 @@ try:
except RpcError as e: except RpcError as e:
raise raise
finally: finally:
core.__versrion__ = None drone.disconnect()
core.__version__ = orig_version
suite.test_end(passed) suite.test_end(passed)
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
@ -295,7 +301,6 @@ try:
drone.clearStats(rx_port) drone.clearStats(rx_port)
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
# TODO:
# TESTCASE: Verify a RPC with missing required fields in request fails # TESTCASE: Verify a RPC with missing required fields in request fails
# and subsequently passes when the fields are initialized # and subsequently passes when the fields are initialized
# ----------------------------------------------------------------- # # ----------------------------------------------------------------- #
@ -303,10 +308,9 @@ try:
suite.test_begin('rpcWithMissingRequiredFieldsFails') suite.test_begin('rpcWithMissingRequiredFieldsFails')
pid = ost_pb.PortId() pid = ost_pb.PortId()
try: try:
drone.getStreamIdList(pid) sid_list = drone.getStreamIdList(pid)
except: except RpcError as e:
e = sys.exc_info()[0] if ('missing required fields in request' in str(e)):
if ('EncodeError' in str(e)):
passed = True passed = True
log.info("Retrying RPC after adding the missing fields") log.info("Retrying RPC after adding the missing fields")
pid.id = tx_port_number pid.id = tx_port_number