Repository: impala Updated Branches: refs/heads/master 0b9334a56 -> 4653637b9
IMPALA-6933: Avoids db name collisions for Kudu tests Kudu tests generate temporary db names in a way so that its unlikely, yet possible to collide. A recent test failure indicates such a collision came up. The fix changes the way that the name is generated so that it includes the classes name for which the db name is generated. This db name will make it easier to see which test created it and the name will not collide with other names generated by other tests. Testing: - ran the updated test locally Change-Id: I7c2f8a35fec90ae0dabe80237d83954668b47f6e Reviewed-on: http://gerrit.cloudera.org:8080/10513 Reviewed-by: Michael Brown <[email protected]> Tested-by: Impala Public Jenkins <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/impala/repo Commit: http://git-wip-us.apache.org/repos/asf/impala/commit/4653637b Tree: http://git-wip-us.apache.org/repos/asf/impala/tree/4653637b Diff: http://git-wip-us.apache.org/repos/asf/impala/diff/4653637b Branch: refs/heads/master Commit: 4653637b9e2ee573f3ad7a76da8941a0a4870bd8 Parents: 0b9334a Author: Vuk Ercegovac <[email protected]> Authored: Thu May 24 23:38:18 2018 -0700 Committer: Impala Public Jenkins <[email protected]> Committed: Tue May 29 20:03:54 2018 +0000 ---------------------------------------------------------------------- tests/common/kudu_test_suite.py | 11 +++++++---- tests/conftest.py | 23 ++++++++++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/impala/blob/4653637b/tests/common/kudu_test_suite.py ---------------------------------------------------------------------- diff --git a/tests/common/kudu_test_suite.py b/tests/common/kudu_test_suite.py index 05d595e..876752b 100644 --- a/tests/common/kudu_test_suite.py +++ b/tests/common/kudu_test_suite.py @@ -74,13 +74,16 @@ class KuduTestSuite(ImpalaTestSuite): def get_db_name(cls): # When py.test runs with the xdist plugin, several processes are started and each # process runs some partition of the tests. It's possible that multiple processes - # will call this method. A random value is generated so the processes won't try - # to use the same database at the same time. The value is cached so within a single + # will call this method. To avoid multiple processes using the same database at the + # same time, the database name is formed by concatenating the test class name, the pid + # and a random value. The class name distinguishes classes and the pid distinguishes + # the same class run in different processes. The value is cached so within a single # process the same database name is always used for the class. This doesn't need to # be thread-safe since multi-threading is never used. if not cls.__DB_NAME: - cls.__DB_NAME = \ - choice(ascii_lowercase) + "".join(sample(ascii_lowercase + digits, 5)) + salt = choice(ascii_lowercase) + "".join(sample(ascii_lowercase + digits, 5)) + cls.__DB_NAME = cls.__name__.lower() + "_" + str(os.getpid()) + "_" + salt + return cls.__DB_NAME @classmethod http://git-wip-us.apache.org/repos/asf/impala/blob/4653637b/tests/conftest.py ---------------------------------------------------------------------- diff --git a/tests/conftest.py b/tests/conftest.py index 1e6adda..fe6b332 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -344,7 +344,8 @@ def conn(request): - get_conn_timeout(): The timeout, in seconds, to use for this connection. The returned connection will have a 'db_name' property. - See the 'unique_database' fixture above if you want to use Impala's custom python + DEPRECATED: + See the 'unique_database' fixture above to use Impala's custom python API instead of DB-API. """ db_name = __call_cls_method_if_exists(request.cls, "get_db_name") @@ -380,6 +381,10 @@ def __unique_conn(db_name=None, timeout=DEFAULT_CONN_TIMEOUT): # The database no longer exists and the conn is closed. The returned connection will have a 'db_name' property. + + DEPRECATED: + See the 'unique_database' fixture above to use Impala's custom python + API instead of DB-API. """ if not db_name: db_name = choice(ascii_lowercase) + "".join(sample(ascii_lowercase + digits, 5)) @@ -407,6 +412,10 @@ def __auto_closed_conn(db_name=None, timeout=DEFAULT_CONN_TIMEOUT): The connection will be closed upon exiting the block. The returned connection will have a 'db_name' property. + + DEPRECATED: + See the 'unique_database' fixture above to use Impala's custom python + API instead of DB-API. """ default_impalad = pytest.config.option.impalad.split(',')[0] impalad_host = default_impalad.split(':')[0] @@ -431,6 +440,10 @@ def cursor(conn): The returned cursor will have a 'conn' property. The 'conn' will have a 'db_name' property. + + DEPRECATED: + See the 'unique_database' fixture above to use Impala's custom python + API instead of DB-API. """ with __auto_closed_cursor(conn) as cur: yield cur @@ -443,6 +456,10 @@ def cls_cursor(conn): The returned cursor will have a 'conn' property. The 'conn' will have a 'db_name' property. + + DEPRECATED: + See the 'unique_database' fixture above to use Impala's custom python + API instead of DB-API. """ with __auto_closed_cursor(conn) as cur: yield cur @@ -456,6 +473,10 @@ def unique_cursor(): The returned cursor will have a 'conn' property. The 'conn' will have a 'db_name' property. + + DEPRECATED: + See the 'unique_database' fixture above to use Impala's custom python + API instead of DB-API. """ with __unique_conn() as conn: with __auto_closed_cursor(conn) as cur:
