Exemple #1
0
    def test_manual_reconnect(self):
        p = ImpalaShell()
        p.send_cmd("USE functional")
        p.send_cmd("CONNECT")
        p.send_cmd("SHOW TABLES")

        result = p.get_result()
        assert "alltypesaggmultifilesnopart" in result.stdout
    def test_manual_reconnect(self):
        # 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)
            p.send_cmd("USE functional")
            # Connect without arguments works because the custom cluster will have the default
            # HS2 and Beeswax ports.
            p.send_cmd("CONNECT")
            p.send_cmd("SHOW TABLES")

            result = p.get_result()
            assert "alltypesaggmultifilesnopart" in result.stdout, result.stdout
Exemple #3
0
    def test_ssl(self, vector):

        self._verify_negative_cases(vector)
        # TODO: This is really two different tests, but the custom cluster takes too long to
        # start. Make it so that custom clusters can be specified across test suites.
        self._validate_positive_cases(vector,
                                      "%s/server-cert.pem" % self.CERT_DIR)

        # No certificate checking: will accept any cert.
        self._validate_positive_cases(vector, )

        # Test cancelling a query
        impalad = ImpaladService(socket.getfqdn())
        assert impalad.wait_for_num_in_flight_queries(0)
        impalad.wait_for_metric_value(
            'impala-server.backend-num-queries-executing', 0)
        p = ImpalaShell(vector, args=["--ssl"])
        p.send_cmd("SET DEBUG_ACTION=0:OPEN:WAIT")
        p.send_cmd("select count(*) from functional.alltypes")
        # Wait until the query has been planned and started executing, at which point it
        # should be cancellable.
        impalad.wait_for_metric_value(
            'impala-server.backend-num-queries-executing', 1, timeout=60)

        LOG = logging.getLogger('test_client_ssl')
        LOG.info("Cancelling query")
        num_tries = 0
        # In practice, sending SIGINT to the shell process doesn't always seem to get caught
        # (and a search shows up some bugs in Python where SIGINT might be ignored). So retry
        # for 30s until one signal takes.
        while impalad.get_num_in_flight_queries() == 1:
            time.sleep(1)
            LOG.info("Sending signal...")
            os.kill(p.pid(), signal.SIGINT)
            num_tries += 1
            assert num_tries < 30, (
                "SIGINT was not caught by shell within 30s. Queries: " +
                json.dumps(impalad.get_queries_json(), indent=2))

        p.send_cmd("profile")
        result = p.get_result()

        print result.stderr
        assert "Query Status: Cancelled" in result.stdout
        assert impalad.wait_for_num_in_flight_queries(0)
Exemple #4
0
    def test_ssl(self, vector):

        self._verify_negative_cases()
        # TODO: This is really two different tests, but the custom cluster takes too long to
        # start. Make it so that custom clusters can be specified across test suites.
        self._validate_positive_cases("%s/server-cert.pem" % self.CERT_DIR)

        # No certificate checking: will accept any cert.
        self._validate_positive_cases()

        # Test cancelling a query
        impalad = ImpaladService(socket.getfqdn())
        impalad.wait_for_num_in_flight_queries(0)
        p = ImpalaShell(args="--ssl")
        p.send_cmd("SET DEBUG_ACTION=0:OPEN:WAIT")
        p.send_cmd("select count(*) from functional.alltypes")
        impalad.wait_for_num_in_flight_queries(1)

        LOG = logging.getLogger('test_client_ssl')
        LOG.info("Cancelling query")
        num_tries = 0
        # In practice, sending SIGINT to the shell process doesn't always seem to get caught
        # (and a search shows up some bugs in Python where SIGINT might be ignored). So retry
        # for 30s until one signal takes.
        while impalad.get_num_in_flight_queries() == 1:
            time.sleep(1)
            LOG.info("Sending signal...")
            os.kill(p.pid(), signal.SIGINT)
            num_tries += 1
            assert num_tries < 30, "SIGINT was not caught by shell within 30s"

        p.send_cmd("profile")
        result = p.get_result()

        print result.stderr
        assert result.rc == 0
        assert "Query Status: Cancelled" in result.stdout
        assert impalad.wait_for_num_in_flight_queries(0)
  def test_ssl(self, vector):
    # TODO: This is really two different tests, but the custom cluster takes too long to
    # start. Make it so that custom clusters can be specified across test suites.
    result = run_impala_shell_cmd("--ssl --ca_cert=%s/server-cert.pem -q 'select 1 + 2'"
                                  % self.CERT_DIR)
    for msg in [self.SSL_ENABLED, self.CONNECTED, self.FETCHED]:
      assert msg in result.stderr

    # No certificate checking: will accept any cert.
    result = run_impala_shell_cmd("--ssl -q 'select 1 + 2'")
    for msg in [self.SSL_ENABLED, self.CONNECTED, self.FETCHED]:
      assert msg in result.stderr

    # Test cancelling a query
    impalad = ImpaladService(socket.getfqdn())
    impalad.wait_for_num_in_flight_queries(0)
    p = ImpalaShell(args="--ssl")
    p.send_cmd("SET DEBUG_ACTION=0:OPEN:WAIT")
    p.send_cmd("select count(*) from functional.alltypes")
    impalad.wait_for_num_in_flight_queries(1)

    LOG = logging.getLogger('test_client_ssl')
    LOG.info("Cancelling query")
    num_tries = 0
    # In practice, sending SIGINT to the shell process doesn't always seem to get caught
    # (and a search shows up some bugs in Python where SIGINT might be ignored). So retry
    # for 30s until one signal takes.
    while impalad.get_num_in_flight_queries() == 1:
      time.sleep(1)
      LOG.info("Sending signal...")
      os.kill(p.pid(), signal.SIGINT)
      num_tries += 1
      assert num_tries < 30, "SIGINT was not caught by shell within 30s"

    p.send_cmd("profile")
    result = p.get_result()

    print result.stderr
    assert result.rc == 0
    assert "Query Status: Cancelled" in result.stdout
    assert impalad.wait_for_num_in_flight_queries(0)
Exemple #6
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
    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