def test_ddl_queries_are_closed(self):
    """Regression test for IMPALA-1317

    The shell does not call close() for alter, use and drop queries, leaving them in
    flight. This test issues those queries in interactive mode, and checks the debug
    webpage to confirm that they've been closed.
    TODO: Add every statement type.
    """

    TMP_DB = 'inflight_test_db'
    TMP_TBL = 'tmp_tbl'
    MSG = '%s query should be closed'
    NUM_QUERIES = 'impala-server.num-queries'

    impalad = ImpaladService(socket.getfqdn())
    p = ImpalaShell()
    try:
      start_num_queries = impalad.get_metric_value(NUM_QUERIES)
      p.send_cmd('create database if not exists %s' % TMP_DB)
      p.send_cmd('use %s' % TMP_DB)
      impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 2)
      assert impalad.wait_for_num_in_flight_queries(0), MSG % 'use'
      p.send_cmd('create table %s(i int)' % TMP_TBL)
      p.send_cmd('alter table %s add columns (j int)' % TMP_TBL)
      impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 4)
      assert impalad.wait_for_num_in_flight_queries(0), MSG % 'alter'
      p.send_cmd('drop table %s' % TMP_TBL)
      impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 5)
      assert impalad.wait_for_num_in_flight_queries(0), MSG % 'drop'
    finally:
      run_impala_shell_interactive("drop table if exists %s.%s;" % (TMP_DB, TMP_TBL))
      run_impala_shell_interactive("drop database if exists foo;")
    def test_ddl_queries_are_closed(self):
        """Regression test for IMPALA-1317

    The shell does not call close() for alter, use and drop queries, leaving them in
    flight. This test issues those queries in interactive mode, and checks the debug
    webpage to confirm that they've been closed.
    TODO: Add every statement type.
    """

        TMP_DB = 'inflight_test_db'
        TMP_TBL = 'tmp_tbl'
        MSG = '%s query should be closed'
        NUM_QUERIES = 'impala-server.num-queries'

        impalad = ImpaladService(socket.getfqdn())
        p = ImpalaShell()
        try:
            start_num_queries = impalad.get_metric_value(NUM_QUERIES)
            p.send_cmd('create database if not exists %s' % TMP_DB)
            p.send_cmd('use %s' % TMP_DB)
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 2)
            assert impalad.wait_for_num_in_flight_queries(0), MSG % 'use'
            p.send_cmd('create table %s(i int)' % TMP_TBL)
            p.send_cmd('alter table %s add columns (j int)' % TMP_TBL)
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 4)
            assert impalad.wait_for_num_in_flight_queries(0), MSG % 'alter'
            p.send_cmd('drop table %s' % TMP_TBL)
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 5)
            assert impalad.wait_for_num_in_flight_queries(0), MSG % 'drop'
        finally:
            run_impala_shell_interactive("drop table if exists %s.%s;" %
                                         (TMP_DB, TMP_TBL))
            run_impala_shell_interactive("drop database if exists foo;")
示例#3
0
    def test_auto_reconnect_after_impalad_died(self):
        """Test reconnect after restarting the remote impalad without using connect;"""
        # Use pexpect instead of ImpalaShell() since after using get_result() in ImpalaShell()
        # to check Disconnect, send_cmd() will no longer have any effect so we can not check
        # reconnect.
        impalad = ImpaladService(socket.getfqdn())
        start_num_queries = impalad.get_metric_value(NUM_QUERIES)

        proc = pexpect.spawn(' '.join([SHELL_CMD, "-i localhost:21000"]))
        proc.expect("21000] default>")
        proc.sendline("use tpch;")

        # wait for the USE command to finish
        impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 1)
        impalad.wait_for_num_in_flight_queries(0)

        # Disconnect
        self.cluster.impalads[0].kill()
        proc.sendline("show tables;")
        # Search from [1:] since the square brackets "[]" are special characters in regex
        proc.expect(ImpalaShellClass.DISCONNECTED_PROMPT[1:])
        # Restarting Impalad
        self.cluster.impalads[0].start()
        # Check reconnect
        proc.sendline("show tables;")
        proc.expect("nation")
        proc.expect("21000] tpch>")
    def test_auto_reconnect_after_impalad_died(self):
        """Test reconnect after restarting the remote impalad without using connect;"""
        # Use pexpect instead of ImpalaShell() since after using get_result() in ImpalaShell()
        # to check Disconnect, send_cmd() will no longer have any effect so we can not check
        # reconnect.
        impalad = ImpaladService(socket.getfqdn())

        # Iterate over test vector within test function to avoid restarting cluster.
        for vector in [
                ImpalaTestVector([value])
                for value in create_beeswax_dimension()
        ]:
            cmd = get_shell_cmd(vector)
            proc = pexpect.spawn(cmd[0], cmd[1:])
            proc.expect("{0}] default>".format(get_impalad_port(vector)))
            # ImpalaShell startup may issue query to get server info - get num queries after
            # starting shell.
            start_num_queries = impalad.get_metric_value(NUM_QUERIES)
            proc.sendline("use tpch;")

            # wait for the USE command to finish
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 1)
            assert impalad.wait_for_num_in_flight_queries(0)

            # Disconnect
            self.cluster.impalads[0].kill()
            proc.sendline("show tables;")
            # Search from [1:] since the square brackets "[]" are special characters in regex
            proc.expect(ImpalaShellClass.DISCONNECTED_PROMPT[1:])
            # Restarting Impalad
            self.cluster.impalads[0].start()
            # Check reconnect
            proc.sendline("show tables;")
            proc.expect("nation")
            proc.expect("{0}] tpch>".format(get_impalad_port(vector)))
示例#5
0
    def test_auto_reconnect(self):
        impalad = ImpaladService(socket.getfqdn())
        start_num_queries = impalad.get_metric_value(NUM_QUERIES)

        p = ImpalaShell()
        p.send_cmd("USE functional")

        # wait for the USE command to finish
        impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 1)
        impalad.wait_for_num_in_flight_queries(0)

        self._start_impala_cluster([])

        p.send_cmd("SHOW TABLES")
        result = p.get_result()
        assert "alltypesaggmultifilesnopart" in result.stdout
示例#6
0
    def test_ddl_queries_are_closed(self, vector):
        """Regression test for IMPALA-1317

    The shell does not call close() for alter, use and drop queries, leaving them in
    flight. This test issues those queries in interactive mode, and checks the debug
    webpage to confirm that they've been closed.
    TODO: Add every statement type.
    """
        # Disconnect existing clients so there are no open sessions.
        self.close_impala_clients()

        TMP_DB = 'inflight_test_db'
        TMP_TBL = 'tmp_tbl'
        MSG = '%s query should be closed'
        NUM_QUERIES = 'impala-server.num-queries'

        impalad = ImpaladService(socket.getfqdn())
        self._wait_for_num_open_sessions(
            vector, impalad, 0,
            "Open sessions found after closing all clients.")
        p = ImpalaShell(vector)
        try:
            start_num_queries = impalad.get_metric_value(NUM_QUERIES)
            p.send_cmd('create database if not exists %s' % TMP_DB)
            p.send_cmd('use %s' % TMP_DB)
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 2)
            assert impalad.wait_for_num_in_flight_queries(0), MSG % 'use'
            p.send_cmd('create table %s(i int)' % TMP_TBL)
            p.send_cmd('alter table %s add columns (j int)' % TMP_TBL)
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 4)
            assert impalad.wait_for_num_in_flight_queries(0), MSG % 'alter'
            p.send_cmd('drop table %s' % TMP_TBL)
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 5)
            assert impalad.wait_for_num_in_flight_queries(0), MSG % 'drop'
        finally:
            # get_result() must be called to exit the shell.
            p.get_result()
            self._wait_for_num_open_sessions(vector, impalad, 0,
                                             "shell should close sessions.")
            run_impala_shell_interactive(
                vector, "drop table if exists %s.%s;" % (TMP_DB, TMP_TBL))
            run_impala_shell_interactive(vector,
                                         "drop database if exists foo;")
            self.create_impala_clients()
    def test_auto_reconnect(self):
        impalad = ImpaladService(socket.getfqdn())

        # Iterate over test vector within test function to avoid restarting cluster.
        for vector in\
            [ImpalaTestVector([value]) for value in create_client_protocol_dimension()]:
            p = ImpalaShell(vector)
            # ImpalaShell startup may issue query to get server info - get num queries after
            # starting shell.
            start_num_queries = impalad.get_metric_value(NUM_QUERIES)
            p.send_cmd("USE functional")

            # wait for the USE command to finish
            impalad.wait_for_metric_value(NUM_QUERIES, start_num_queries + 1)
            assert impalad.wait_for_num_in_flight_queries(0)

            self._start_impala_cluster([])

            p.send_cmd("SHOW TABLES")
            result = p.get_result()
            assert "alltypesaggmultifilesnopart" in result.stdout, result.stdout