コード例 #1
0
 def test_cancellation(self):
   impalad = ImpaladService(socket.getfqdn())
   impalad.wait_for_num_in_flight_queries(0)
   command = "select sleep(10000);"
   p = self._start_new_shell_process()
   self._send_cmd_to_shell(p, command)
   sleep(3)
   os.kill(p.pid, signal.SIGINT)
   get_shell_cmd_result(p)
   assert impalad.wait_for_num_in_flight_queries(0)
コード例 #2
0
 def test_cancellation(self):
     impalad = ImpaladService(socket.getfqdn())
     impalad.wait_for_num_in_flight_queries(0)
     command = "select sleep(10000);"
     p = self._start_new_shell_process()
     self._send_cmd_to_shell(p, command)
     sleep(3)
     os.kill(p.pid, signal.SIGINT)
     get_shell_cmd_result(p)
     assert impalad.wait_for_num_in_flight_queries(0)
コード例 #3
0
def run_impala_shell_interactive(command, shell_args=''):
  """Runs a command in the Impala shell interactively."""
  cmd = "%s %s" % (SHELL_CMD, shell_args)
  p = Popen(shlex.split(cmd), shell=False, stdout=PIPE, stdin=PIPE, stderr=PIPE)
  p.stdin.write(command + "\n")
  p.stdin.flush()
  return get_shell_cmd_result(p)
コード例 #4
0
    def test_multiline_queries_in_history(self):
        """Test to ensure that multiline queries with comments are preserved in history

    Ensure that multiline queries are preserved when they're read back from history.
    Additionally, also test that comments are preserved.
    """
        # regex for pexpect, a shell prompt is expected after each command..
        prompt_regex = '.*%s:2100.*' % socket.getfqdn()
        # readline gets its input from tty, so using stdin does not work.
        child_proc = pexpect.spawn(SHELL_CMD)
        queries = [
            "select\n1--comment;", "select /*comment*/\n1;",
            "select\n/*comm\nent*/\n1;"
        ]
        for query in queries:
            child_proc.expect(prompt_regex)
            child_proc.sendline(query)
        child_proc.expect(prompt_regex)
        child_proc.sendline('quit;')
        p = self._start_new_shell_process()
        self._send_cmd_to_shell(p, 'history')
        result = get_shell_cmd_result(p)
        for query in queries:
            assert query in result.stderr, "'%s' not in '%s'" % (query,
                                                                 result.stderr)
コード例 #5
0
 def test_cancellation(self):
   command = "select sleep(10000);"
   p = self._start_new_shell_process()
   self._send_cmd_to_shell(p, command)
   sleep(1)
   # iterate through all processes with psutil
   shell_pid = cancellation_helper()
   sleep(2)
   os.kill(shell_pid, signal.SIGINT)
   result = get_shell_cmd_result(p)
   assert "Cancelling Query" in result.stderr
コード例 #6
0
  def test_cancellation(self):
    """Test cancellation (Ctrl+C event)"""
    args = '-q "select sleep(10000)"'
    cmd = "%s %s" % (SHELL_CMD, args)

    p = Popen(shlex.split(cmd), stderr=PIPE, stdout=PIPE)
    sleep(3)
    os.kill(p.pid, signal.SIGINT)
    result = get_shell_cmd_result(p)

    assert "Cancelling Query" in result.stderr, result.stderr
コード例 #7
0
def run_impala_shell_interactive(command, shell_args=''):
  """Runs a command in the Impala shell interactively."""
  cmd = "%s %s" % (SHELL_CMD, shell_args)
  # workaround to make Popen environment 'utf-8' compatible
  # since piping defaults to ascii
  my_env = os.environ
  my_env['PYTHONIOENCODING'] = 'utf-8'
  p = Popen(shlex.split(cmd), shell=True, stdout=PIPE,
            stdin=PIPE, stderr=PIPE, env=my_env)
  p.stdin.write(command + "\n")
  p.stdin.flush()
  return get_shell_cmd_result(p)
コード例 #8
0
 def test_cancellation(self):
   command = "select sleep(10000);"
   p = Popen(shlex.split(SHELL_CMD), shell=True, stdout=PIPE, stdin=PIPE, stderr=PIPE)
   p.stdin.write(command + "\n")
   p.stdin.flush()
   sleep(1)
   # iterate through all processes with psutil
   shell_pid = cancellation_helper()
   sleep(2)
   os.kill(shell_pid, signal.SIGINT)
   result = get_shell_cmd_result(p)
   assert "Cancelling Query" in result.stderr
コード例 #9
0
 def test_compute_stats_with_live_progress_options(self):
   """Test that setting LIVE_PROGRESS options won't cause COMPUTE STATS query fail"""
   impalad = ImpaladService(socket.getfqdn())
   p = self._start_new_shell_process()
   self._send_cmd_to_shell(p, "set live_progress=True")
   self._send_cmd_to_shell(p, "set live_summary=True")
   self._send_cmd_to_shell(p, 'create table test_live_progress_option(col int);')
   try:
     self._send_cmd_to_shell(p, 'compute stats test_live_progress_option;')
   finally:
     self._send_cmd_to_shell(p, 'drop table if exists test_live_progress_option;')
   result = get_shell_cmd_result(p)
   assert "Updated 1 partition(s) and 1 column(s)" in result.stdout
コード例 #10
0
 def test_compute_stats_with_live_progress_options(self):
   """Test that setting LIVE_PROGRESS options won't cause COMPUTE STATS query fail"""
   impalad = ImpaladService(socket.getfqdn())
   p = self._start_new_shell_process()
   self._send_cmd_to_shell(p, "set live_progress=True")
   self._send_cmd_to_shell(p, "set live_summary=True")
   self._send_cmd_to_shell(p, 'create table test_live_progress_option(col int);')
   try:
     self._send_cmd_to_shell(p, 'compute stats test_live_progress_option;')
   finally:
     self._send_cmd_to_shell(p, 'drop table if exists test_live_progress_option;')
   result = get_shell_cmd_result(p)
   assert "Updated 1 partition(s) and 1 column(s)" in result.stdout
コード例 #11
0
 def test_cancellation(self):
   impalad = ImpaladService(socket.getfqdn())
   impalad.wait_for_num_in_flight_queries(0)
   command = "select sleep(10000);"
   p = self._start_new_shell_process()
   self._send_cmd_to_shell(p, command)
   sleep(1)
   # iterate through all processes with psutil
   shell_pid = cancellation_helper()
   sleep(2)
   os.kill(shell_pid, signal.SIGINT)
   result = get_shell_cmd_result(p)
   assert impalad.wait_for_num_in_flight_queries(0)
コード例 #12
0
 def test_cancellation(self):
     impalad = ImpaladService(socket.getfqdn())
     impalad.wait_for_num_in_flight_queries(0)
     command = "select sleep(10000);"
     p = self._start_new_shell_process()
     self._send_cmd_to_shell(p, command)
     sleep(1)
     # iterate through all processes with psutil
     shell_pid = cancellation_helper()
     sleep(2)
     os.kill(shell_pid, signal.SIGINT)
     result = get_shell_cmd_result(p)
     assert impalad.wait_for_num_in_flight_queries(0)
コード例 #13
0
  def test_cancellation(self):
    """Test cancellation (Ctrl+C event)"""
    args = '-q "select sleep(10000)"'
    cmd = "%s %s" % (SHELL_CMD, args)

    p = Popen(shlex.split(cmd), shell=False, stderr=PIPE, stdout=PIPE)
    sleep(1)
    # iterate through all processes with psutil
    shell_pid = cancellation_helper(args)
    sleep(2)
    os.kill(shell_pid, signal.SIGINT)
    result = get_shell_cmd_result(p)

    assert "Cancelling Query" in result.stderr, result.stderr
コード例 #14
0
  def test_queries_closed(self):
    """Regression test for IMPALA-897"""
    args = '-f %s/test_close_queries.sql --quiet -B' % QUERY_FILE_PATH
    cmd = "%s %s" % (SHELL_CMD, args)
    # Execute the shell command async
    p = Popen(shlex.split(cmd), shell=False, stdout=PIPE, stderr=PIPE)

    impalad_service = ImpaladService(IMPALAD.split(':')[0])
    # The last query in the test SQL script will sleep for 10 seconds, so sleep
    # here for 5 seconds and verify the number of in-flight queries is 1.
    sleep(5)
    assert 1 == impalad_service.get_num_in_flight_queries()
    assert get_shell_cmd_result(p).rc == 0
    assert 0 == impalad_service.get_num_in_flight_queries()
コード例 #15
0
def run_impala_shell_cmd(shell_args, expect_success=True):
  """Runs the Impala shell on the commandline.

  'shell_args' is a string which represents the commandline options.
  Returns a ImpalaShellResult.
  """
  cmd = "%s %s" % (SHELL_CMD, shell_args)
  p = Popen(shlex.split(cmd), shell=False, stdout=PIPE, stderr=PIPE)
  result = get_shell_cmd_result(p)
  if expect_success:
    assert result.rc == 0, "Cmd %s was expected to succeed: %s" % (cmd, result.stderr)
  else:
    assert result.rc != 0, "Cmd %s was expected to fail" % cmd
  return result
コード例 #16
0
    def test_queries_closed(self):
        """Regression test for IMPALA-897"""
        args = '-f %s/test_close_queries.sql --quiet -B' % QUERY_FILE_PATH
        cmd = "%s %s" % (SHELL_CMD, args)
        # Execute the shell command async
        p = Popen(shlex.split(cmd), shell=False, stdout=PIPE, stderr=PIPE)

        impalad_service = ImpaladService(IMPALAD.split(':')[0])
        # The last query in the test SQL script will sleep for 10 seconds, so sleep
        # here for 5 seconds and verify the number of in-flight queries is 1.
        sleep(5)
        assert 1 == impalad_service.get_num_in_flight_queries()
        assert get_shell_cmd_result(p).rc == 0
        assert 0 == impalad_service.get_num_in_flight_queries()
コード例 #17
0
def run_impala_shell_cmd(shell_args, expect_success=True, stdin_input=None):
  """Runs the Impala shell on the commandline.

  'shell_args' is a string which represents the commandline options.
  Returns a ImpalaShellResult.
  """
  cmd = "%s %s" % (SHELL_CMD, shell_args)
  p = Popen(shlex.split(cmd), shell=False, stdout=PIPE, stderr=PIPE, stdin=PIPE)
  result = get_shell_cmd_result(p, stdin_input)
  if expect_success:
    assert result.rc == 0, "Cmd %s was expected to succeed: %s" % (cmd, result.stderr)
  else:
    assert result.rc != 0, "Cmd %s was expected to fail" % cmd
  return result
コード例 #18
0
def run_impala_shell_interactive(input_lines, shell_args=''):
  """Runs a command in the Impala shell interactively."""
  cmd = "%s %s" % (SHELL_CMD, shell_args)
  # if argument "input_lines" is a string, makes it into a list
  if type(input_lines) is str:
    input_lines = [input_lines]
  # workaround to make Popen environment 'utf-8' compatible
  # since piping defaults to ascii
  my_env = os.environ
  my_env['PYTHONIOENCODING'] = 'utf-8'
  p = Popen(cmd, shell=True, stdout=PIPE,
            stdin=PIPE, stderr=PIPE, env=my_env)
  for line in input_lines:
    p.stdin.write(line + "\n")
    p.stdin.flush()
  return get_shell_cmd_result(p)
コード例 #19
0
 def test_cancellation(self):
     command = "select sleep(10000);"
     p = Popen(shlex.split(SHELL_CMD),
               shell=True,
               stdout=PIPE,
               stdin=PIPE,
               stderr=PIPE)
     p.stdin.write(command + "\n")
     p.stdin.flush()
     sleep(1)
     # iterate through all processes with psutil
     shell_pid = cancellation_helper()
     sleep(2)
     os.kill(shell_pid, signal.SIGINT)
     result = get_shell_cmd_result(p)
     assert "Cancelling Query" in result.stderr
コード例 #20
0
def run_impala_shell_interactive(command, shell_args=''):
    """Runs a command in the Impala shell interactively."""
    cmd = "%s %s" % (SHELL_CMD, shell_args)
    # workaround to make Popen environment 'utf-8' compatible
    # since piping defaults to ascii
    my_env = os.environ
    my_env['PYTHONIOENCODING'] = 'utf-8'
    p = Popen(shlex.split(cmd),
              shell=True,
              stdout=PIPE,
              stdin=PIPE,
              stderr=PIPE,
              env=my_env)
    p.stdin.write(command + "\n")
    p.stdin.flush()
    return get_shell_cmd_result(p)
コード例 #21
0
  def test_multiline_queries_in_history(self):
    """Test to ensure that multiline queries with comments are preserved in history

    Ensure that multiline queries are preserved when they're read back from history.
    Additionally, also test that comments are preserved.
    """
    # regex for pexpect, a shell prompt is expected after each command..
    prompt_regex = '.*%s:2100.*' % socket.getfqdn()
    # readline gets its input from tty, so using stdin does not work.
    child_proc = pexpect.spawn(SHELL_CMD)
    queries = ["select\n1--comment;",
        "select /*comment*/\n1;",
        "select\n/*comm\nent*/\n1;"]
    for query in queries:
      child_proc.expect(prompt_regex)
      child_proc.sendline(query)
    child_proc.expect(prompt_regex)
    child_proc.sendline('quit;')
    p = self._start_new_shell_process()
    self._send_cmd_to_shell(p, 'history')
    result = get_shell_cmd_result(p)
    for query in queries:
      assert query in result.stderr, "'%s' not in '%s'" % (query, result.stderr)