Beispiel #1
0
    def test_close_session(self):
        """Test that an open session can be closed"""
        open_session_req = TCLIService.TOpenSessionReq()
        resp = self.hs2_client.OpenSession(open_session_req)
        TestHS2.check_response(resp)

        close_session_req = TCLIService.TCloseSessionReq()
        close_session_req.sessionHandle = resp.sessionHandle
        TestHS2.check_response(self.hs2_client.CloseSession(close_session_req))
Beispiel #2
0
    def test_double_close_session(self):
        """Test that an already closed session cannot be closed a second time"""
        open_session_req = TCLIService.TOpenSessionReq()
        resp = self.hs2_client.OpenSession(open_session_req)
        TestHS2.check_response(resp)

        close_session_req = TCLIService.TCloseSessionReq()
        close_session_req.sessionHandle = resp.sessionHandle
        TestHS2.check_response(self.hs2_client.CloseSession(close_session_req))

        # Double close should be an error
        TestHS2.check_response(self.hs2_client.CloseSession(close_session_req),
                               TCLIService.TStatusCode.ERROR_STATUS)
Beispiel #3
0
 def add_session(self):
     open_session_req = TCLIService.TOpenSessionReq()
     open_session_req.username = getuser()
     open_session_req.configuration = dict()
     resp = self.hs2_client.OpenSession(open_session_req)
     HS2TestSuite.check_response(resp)
     self.session_handle = resp.sessionHandle
     try:
         fn(self)
     finally:
         close_session_req = TCLIService.TCloseSessionReq()
         close_session_req.sessionHandle = resp.sessionHandle
         HS2TestSuite.check_response(
             self.hs2_client.CloseSession(close_session_req))
         self.session_handle = None
Beispiel #4
0
                  help="Indicates whether the cluster is kerberized.")
options, args = parser.parse_args()

hs2_host, hs2_port = options.hs2_hostport.split(':')
hs2_transport = create_transport(use_kerberos=options.use_kerberos, host=hs2_host,
                                 port=hs2_port, service="hiveserver2")
protocol = TBinaryProtocol.TBinaryProtocol(hs2_transport)
hs2_client = TCLIService.Client(protocol)

# Try to connect to the HiveServer2 service and create a session
now = time.time()
TIMEOUT_SECONDS = 30.0
while time.time() - now < TIMEOUT_SECONDS:
  try:
    hs2_transport.open()
    open_session_req = TCLIService.TOpenSessionReq()
    open_session_req.username = getpass.getuser()
    resp = hs2_client.OpenSession(open_session_req)
    if resp.status.statusCode == TCLIService.TStatusCode.SUCCESS_STATUS:
      close_session_req = TCLIService.TCloseSessionReq()
      close_session_req.sessionHandle = resp.sessionHandle
      hs2_client.CloseSession(close_session_req)
      print "HiveServer2 service is up at %s." % options.hs2_hostport
      exit(0)
  except Exception, e:
    print "Waiting for HiveServer2 at %s..." % options.hs2_hostport
  time.sleep(0.5)

print "HiveServer2 service failed to start within %s seconds." % TIMEOUT_SECONDS
exit(1)