Ejemplo n.º 1
0
    def test_get_operation_status(self):
        """Tests that GetOperationStatus returns a valid result for a running query"""
        execute_statement_req = TCLIService.TExecuteStatementReq()
        execute_statement_req.sessionHandle = self.session_handle
        execute_statement_req.statement = "SELECT COUNT(*) FROM functional.alltypes"
        execute_statement_resp = self.hs2_client.ExecuteStatement(
            execute_statement_req)
        TestHS2.check_response(execute_statement_resp)

        get_operation_status_req = TCLIService.TGetOperationStatusReq()
        get_operation_status_req.operationHandle = execute_statement_resp.operationHandle

        get_operation_status_resp = \
            self.hs2_client.GetOperationStatus(get_operation_status_req)
        TestHS2.check_response(get_operation_status_resp)

        assert get_operation_status_resp.operationState in \
            [TCLIService.TOperationState.INITIALIZED_STATE,
             TCLIService.TOperationState.RUNNING_STATE,
             TCLIService.TOperationState.FINISHED_STATE]
Ejemplo n.º 2
0
    def test_malformed_get_operation_status(self):
        """Tests that a short guid / secret returns an error (regression would be to crash
    impalad)"""
        operation_handle = TCLIService.TOperationHandle()
        operation_handle.operationId = TCLIService.THandleIdentifier()
        operation_handle.operationId.guid = "short"
        operation_handle.operationId.secret = "short_secret"
        assert len(operation_handle.operationId.guid) != 16
        assert len(operation_handle.operationId.secret) != 16
        operation_handle.operationType = TCLIService.TOperationType.EXECUTE_STATEMENT
        operation_handle.hasResultSet = False

        get_operation_status_req = TCLIService.TGetOperationStatusReq()
        get_operation_status_req.operationHandle = operation_handle

        get_operation_status_resp = \
            self.hs2_client.GetOperationStatus(get_operation_status_req)
        TestHS2.check_response(get_operation_status_resp,
                               TCLIService.TStatusCode.ERROR_STATUS)
        err_msg = "(guid size: %d, expected 16, secret size: %d, expected 16)" \
            % (len(operation_handle.operationId.guid),
               len(operation_handle.operationId.secret))
        assert err_msg in get_operation_status_resp.status.errorMessage