Beispiel #1
0
 def _get_handle(self, snippet):
     snippet["result"]["handle"]["secret"], snippet["result"]["handle"]["guid"] = HiveServerQueryHandle.get_decoded(
         snippet["result"]["handle"]["secret"], snippet["result"]["handle"]["guid"]
     )
     snippet["result"]["handle"].pop("statement_id")
     snippet["result"]["handle"].pop("has_more_statements")
     return HiveServerQueryHandle(**snippet["result"]["handle"])
Beispiel #2
0
  def _get_handle(self, snippet):
    snippet['result']['handle']['secret'], snippet['result']['handle']['guid'] = HiveServerQueryHandle.get_decoded(snippet['result']['handle']['secret'], snippet['result']['handle']['guid'])

    for key in snippet['result']['handle'].keys():
      if key not in ('log_context', 'secret', 'has_result_set', 'operation_type', 'modified_row_count', 'guid'):
        snippet['result']['handle'].pop(key)

    return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #3
0
  def _get_handle(self, snippet):
    snippet['result']['handle']['secret'], snippet['result']['handle']['guid'] = HiveServerQueryHandle.get_decoded(snippet['result']['handle']['secret'], snippet['result']['handle']['guid'])

    for key in snippet['result']['handle'].keys():
      if key not in ('log_context', 'secret', 'has_result_set', 'operation_type', 'modified_row_count', 'guid'):
        snippet['result']['handle'].pop(key)

    return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #4
0
 def _get_handle(self, snippet):
     try:
         snippet['result']['handle']['secret'], snippet['result']['handle'][
             'guid'] = HiveServerQueryHandle.get_decoded(
                 snippet['result']['handle']['secret'],
                 snippet['result']['handle']['guid'])
     except KeyError, ex:
         raise Exception('Operation has no valid handle attached')
Beispiel #5
0
 def _get_handle(self, snippet):
     snippet['result']['handle']['secret'], snippet['result']['handle'][
         'guid'] = HiveServerQueryHandle.get_decoded(
             snippet['result']['handle']['secret'],
             snippet['result']['handle']['guid'])
     snippet['result']['handle'].pop('statement_id')
     snippet['result']['handle'].pop('has_more_statements')
     return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #6
0
  def test_open_session(self):
    query = Mock(
      get_query_statement=Mock(return_value=['SELECT 1']),
      settings=[]
    )

    with patch('beeswax.server.hive_server2_lib.thrift_util.get_client') as get_client:
      original_secret = b's\xb6\x0ePP\xbdL\x17\xa3\x0f\\\xf7K\xe8Y\x1d'
      original_guid = b'\xd9\xe0hT\xd6wO\xe1\xa3S\xfb\x04\xca\x93V\x01'
      get_client.return_value = Mock(
        OpenSession=Mock(
          return_value=Mock(
            status=Mock(
              statusCode=TStatusCode.SUCCESS_STATUS
            ),
            configuration={},
            sessionHandle=Mock(
              sessionId=Mock(
                secret=original_secret,
                guid=original_guid
              )
            ),
            serverProtocolVersion=11
          )
        ),
        get_coordinator_host=Mock(return_value='hive-host')
      )
      session_count = Session.objects.filter(owner=self.user, application=self.query_server['server_name']).count()

      # Send open session
      session = HiveServerClient(self.query_server, self.user).open_session(self.user)

      assert_equal(
        session_count + 1,  # +1 as setUp resets the user which deletes cascade the sessions
        Session.objects.filter(owner=self.user, application=self.query_server['server_name']).count()
      )

      session = Session.objects.get_session(self.user, self.query_server['server_name'])
      secret, guid = session.get_adjusted_guid_secret()
      secret, guid = HiveServerQueryHandle.get_decoded(secret, guid)
      assert_equal(
        original_secret,
        secret
      )
      assert_equal(
        original_guid,
        guid
      )
      handle = session.get_handle()
      assert_equal(
        original_secret,
        handle.sessionId.secret
      )
      assert_equal(
        original_guid,
        handle.sessionId.guid
      )
Beispiel #7
0
  def _get_handle(self, snippet):
    try:
      snippet['result']['handle']['secret'], snippet['result']['handle']['guid'] = HiveServerQueryHandle.get_decoded(snippet['result']['handle']['secret'], snippet['result']['handle']['guid'])
    except KeyError:
      raise Exception('Operation has no valid handle attached')

    for key in snippet['result']['handle'].keys():
      if key not in ('log_context', 'secret', 'has_result_set', 'operation_type', 'modified_row_count', 'guid'):
        snippet['result']['handle'].pop(key)

    return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #8
0
  def _get_handle(self, snippet):
    try:
      snippet['result']['handle']['secret'], snippet['result']['handle']['guid'] = HiveServerQueryHandle.get_decoded(snippet['result']['handle']['secret'], snippet['result']['handle']['guid'])
    except KeyError:
      raise Exception('Operation has no valid handle attached')
    except binascii.Error:
      LOG.warn('Handle already base 64 decoded')

    for key in snippet['result']['handle'].keys():
      if key not in ('log_context', 'secret', 'has_result_set', 'operation_type', 'modified_row_count', 'guid'):
        snippet['result']['handle'].pop(key)

    return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #9
0
 def _get_handle(self, snippet):
     snippet['result']['handle']['secret'], snippet['result']['handle'][
         'guid'] = HiveServerQueryHandle.get_decoded(
             snippet['result']['handle']['secret'],
             snippet['result']['handle']['guid'])
     return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #10
0
 def _get_handle(self, snippet):
   snippet['result']['handle']['secret'], snippet['result']['handle']['guid'] = HiveServerQueryHandle.get_decoded(snippet['result']['handle']['secret'], snippet['result']['handle']['guid'])
   return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #11
0
 def _get_handle(self, snippet):
   snippet['result']['handle']['secret'], snippet['result']['handle']['guid'] = HiveServerQueryHandle.get_decoded(snippet['result']['handle']['secret'], snippet['result']['handle']['guid'])
   snippet['result']['handle'].pop('statement_id')
   snippet['result']['handle'].pop('has_more_statements')
   snippet['result']['handle'].pop('statements_count')
   return HiveServerQueryHandle(**snippet['result']['handle'])
Beispiel #12
0
 def _get_handle(self, snippet):
     snippet["result"]["handle"]["secret"], snippet["result"]["handle"]["guid"] = HiveServerQueryHandle.get_decoded(
         snippet["result"]["handle"]["secret"], snippet["result"]["handle"]["guid"]
     )
     return HiveServerQueryHandle(**snippet["result"]["handle"])