Repository: incubator-impala Updated Branches: refs/heads/master bee537550 -> fc444c102
IMPALA-3491: Use unique_database fixture in test_catalog_service_client.py. Even though this is just a single test, this change introduces the unique_database test fixture that was initially created to help with concurrent tests. It's still worth to do this here because we want to update all tests to use best practices. That said, there was still a performance gain to be had here. It turns out the initial code called the cleanup_db() method from the base ImpalaTestSuite class, which in turn sets the 'sync_ddl' query option to true. Not doing this at the beginning of this test results in a roughly 40x speedup. Change-Id: I5d6994f31d52e18e2e04aab0e34202e2c623e367 Reviewed-on: http://gerrit.cloudera.org:8080/3366 Reviewed-by: David Knupp <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/fc444c10 Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/fc444c10 Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/fc444c10 Branch: refs/heads/master Commit: fc444c102ed148140330a70cf3b54980b4f0804c Parents: bee5375 Author: David Knupp <[email protected]> Authored: Fri Jun 10 14:18:51 2016 -0700 Committer: Tim Armstrong <[email protected]> Committed: Mon Jun 13 16:32:22 2016 -0700 ---------------------------------------------------------------------- .../test_catalog_service_client.py | 30 +++++++------------- 1 file changed, 11 insertions(+), 19 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/fc444c10/tests/catalog_service/test_catalog_service_client.py ---------------------------------------------------------------------- diff --git a/tests/catalog_service/test_catalog_service_client.py b/tests/catalog_service/test_catalog_service_client.py index 033b176..9ae05c0 100644 --- a/tests/catalog_service/test_catalog_service_client.py +++ b/tests/catalog_service/test_catalog_service_client.py @@ -37,7 +37,6 @@ LOG = logging.getLogger('test_catalog_service_client') # to create/drop function requests. For example, BDR relies # on a stable catalog Thrift API. class TestCatalogServiceClient(ImpalaTestSuite): - TEST_DB = 'catalog_service_client_test_db' @classmethod def get_workload(cls): @@ -53,15 +52,8 @@ class TestCatalogServiceClient(ImpalaTestSuite): v.get_value('table_format').file_format == 'parquet' and\ v.get_value('table_format').compression_codec == 'none') - def setup_method(self, method): - self.cleanup_db(self.TEST_DB) - self.client.execute("create database %s location '%s/%s.db'" % - (self.TEST_DB, WAREHOUSE, self.TEST_DB)) - def teardown_method(self, method): - self.cleanup_db(self.TEST_DB) - - def test_get_functions(self, vector): + def test_get_functions(self, vector, unique_database): impala_cluster = ImpalaCluster() catalogd = impala_cluster.catalogd.service trans_type = 'buffered' @@ -74,20 +66,20 @@ class TestCatalogServiceClient(ImpalaTestSuite): catalog_client = CatalogService.Client(protocol) request = TGetFunctionsRequest() - request.db_name = self.TEST_DB + request.db_name = unique_database response = catalog_client.GetFunctions(request) assert response.status.status_code == TErrorCode.OK assert len(response.functions) == 0 - # Add a function and make sure it shows up. - self.client.execute("create function %s.fn() RETURNS int "\ - "LOCATION '%s/libTestUdfs.so' SYMBOL='Fn'" % (self.TEST_DB, WAREHOUSE)) + self.client.execute("create function %s.fn() RETURNS int " + "LOCATION '%s/libTestUdfs.so' SYMBOL='Fn'" + % (unique_database, WAREHOUSE)) response = catalog_client.GetFunctions(request) LOG.debug(response) assert len(response.functions) == 1 assert len(response.functions[0].arg_types) == 0 - assert response.functions[0].name.db_name == self.TEST_DB + assert response.functions[0].name.db_name == unique_database assert response.functions[0].name.function_name == 'fn' assert response.functions[0].aggregate_fn is None assert response.functions[0].scalar_fn is not None @@ -95,7 +87,7 @@ class TestCatalogServiceClient(ImpalaTestSuite): # Add another scalar function with overloaded parameters ensure it shows up. self.client.execute("create function %s.fn(int) RETURNS double "\ - "LOCATION '%s/libTestUdfs.so' SYMBOL='Fn'" % (self.TEST_DB, WAREHOUSE)) + "LOCATION '%s/libTestUdfs.so' SYMBOL='Fn'" % (unique_database, WAREHOUSE)) response = catalog_client.GetFunctions(request) LOG.debug(response) assert response.status.status_code == TErrorCode.OK @@ -111,9 +103,9 @@ class TestCatalogServiceClient(ImpalaTestSuite): assert functions[1].signature == 'fn(INT)' # Verify aggregate functions can also be retrieved - self.client.execute("create aggregate function %s.agg_fn(int, string) RETURNS int "\ - "LOCATION '%s/libTestUdas.so' UPDATE_FN='TwoArgUpdate'" % - (self.TEST_DB, WAREHOUSE)) + self.client.execute("create aggregate function %s.agg_fn(int, string) RETURNS int " + "LOCATION '%s/libTestUdas.so' UPDATE_FN='TwoArgUpdate'" + % (unique_database, WAREHOUSE)) response = catalog_client.GetFunctions(request) LOG.debug(response) assert response.status.status_code == TErrorCode.OK @@ -123,7 +115,7 @@ class TestCatalogServiceClient(ImpalaTestSuite): assert len(functions) == 1 # Negative test cases for database name - request.db_name = self.TEST_DB + "_does_not_exist" + request.db_name = unique_database + "_does_not_exist" response = catalog_client.GetFunctions(request) LOG.debug(response) assert response.status.status_code == TErrorCode.GENERAL
