Esempio n. 1
0
def main(argv):
    p = argparse.ArgumentParser()
    add_common_args(p)
    # Since THeaderTransport acts as framed transport when detected frame, we
    # cannot use --transport=framed as it would result in 2 layered frames.
    p.add_argument('--override-transport')
    p.add_argument('--override-protocol')
    args = p.parse_args()
    assert args.protocol == 'header'
    assert args.transport == 'buffered'
    assert not args.ssl

    sock = TSocket(args.host, args.port, socket_family=socket.AF_INET)
    if not args.override_transport or args.override_transport == 'buffered':
        trans = TBufferedTransport(sock)
    elif args.override_transport == 'framed':
        print('TFRAMED')
        trans = TFramedTransport(sock)
    else:
        raise ValueError('invalid transport')
    trans.open()

    if not args.override_protocol or args.override_protocol == 'binary':
        proto = TBinaryProtocol(trans)
    elif args.override_protocol == 'compact':
        proto = TCompactProtocol(trans)
    else:
        raise ValueError('invalid transport')

    test_void(proto)
    test_void(proto)

    trans.close()
Esempio n. 2
0
def main(argv):
  p = argparse.ArgumentParser()
  add_common_args(p)
  # Since THeaderTransport acts as framed transport when detected frame, we
  # cannot use --transport=framed as it would result in 2 layered frames.
  p.add_argument('--override-transport')
  p.add_argument('--override-protocol')
  args = p.parse_args()
  assert args.protocol == 'header'
  assert args.transport == 'buffered'
  assert not args.ssl

  sock = TSocket(args.host, args.port, socket_family=socket.AF_INET)
  if not args.override_transport or args.override_transport == 'buffered':
    trans = TBufferedTransport(sock)
  elif args.override_transport == 'framed':
    print('TFRAMED')
    trans = TFramedTransport(sock)
  else:
    raise ValueError('invalid transport')
  trans.open()

  if not args.override_protocol or args.override_protocol == 'binary':
    proto = TBinaryProtocol(trans)
  elif args.override_protocol == 'compact':
    proto = TCompactProtocol(trans)
  else:
    raise ValueError('invalid transport')

  test_void(proto)
  test_void(proto)

  trans.close()
Esempio n. 3
0
def main(argv):
    p = argparse.ArgumentParser()
    add_common_args(p)
    p.add_argument('--limit', type=int)
    args = p.parse_args()
    proto = init_protocol(args)
    test_string(proto, 'a' * (args.limit - 1))
    test_string(proto, 'a' * (args.limit - 1))
    print('[OK]: limit - 1')
    test_string(proto, 'a' * args.limit)
    test_string(proto, 'a' * args.limit)
    print('[OK]: just limit')
    try:
        test_string(proto, 'a' * (args.limit + 1))
    except:
        print('[OK]: limit + 1')
    else:
        print('[ERROR]: limit + 1')
        assert False
Esempio n. 4
0
def main(argv):
    p = argparse.ArgumentParser()
    add_common_args(p)
    p.add_argument('--limit', type=int)
    args = p.parse_args()
    proto = init_protocol(args)
    test_string(proto, 'a' * (args.limit - 1))
    test_string(proto, 'a' * (args.limit - 1))
    print('[OK]: limit - 1')
    test_string(proto, 'a' * args.limit)
    test_string(proto, 'a' * args.limit)
    print('[OK]: just limit')
    try:
        test_string(proto, 'a' * (args.limit + 1))
    except:
        print('[OK]: limit + 1')
    else:
        print('[ERROR]: limit + 1')
        assert False
Esempio n. 5
0
def main(argv):
    p = argparse.ArgumentParser()
    add_common_args(p)
    p.add_argument('--limit', type=int)
    args = p.parse_args()
    proto = init_protocol(args)
    # TODO: test set and map
    test_list(proto, list(range(args.limit - 1)))
    test_list(proto, list(range(args.limit - 1)))
    print('[OK]: limit - 1')
    test_list(proto, list(range(args.limit)))
    test_list(proto, list(range(args.limit)))
    print('[OK]: just limit')
    try:
        test_list(proto, list(range(args.limit + 1)))
    except Exception:
        print('[OK]: limit + 1')
    else:
        print('[ERROR]: limit + 1')
        assert False
Esempio n. 6
0
def main(argv):
  p = argparse.ArgumentParser()
  add_common_args(p)
  # Since THeaderTransport acts as framed transport when detected frame, we
  # cannot use --transport=framed as it would result in 2 layered frames.
  p.add_argument('--override-transport')
  args = p.parse_args()
  assert args.protocol == 'header'
  assert args.transport == 'buffered'
  assert not args.ssl

  sock = TSocket(args.host, args.port, socket_family=socket.AF_INET)
  if not args.override_transport or args.override_transport == 'buffered':
    trans = TBufferedTransport(sock)
  elif args.override_transport == 'framed':
    trans = TFramedTransport(sock)
  else:
    raise ValueError('invalid transport')
  trans.open()
  proto = TBinaryProtocol(trans)
  proto.writeMessageBegin('testVoid', TMessageType.CALL, 3)
  proto.writeStructBegin('testVoid_args')
  proto.writeFieldStop()
  proto.writeStructEnd()
  proto.writeMessageEnd()
  trans.flush()

  _, mtype, _ = proto.readMessageBegin()
  assert mtype == TMessageType.REPLY
  proto.readStructBegin()
  _, ftype, _ = proto.readFieldBegin()
  assert ftype == TType.STOP
  proto.readFieldEnd()
  proto.readStructEnd()
  proto.readMessageEnd()

  trans.close()