You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by br...@apache.org on 2021/04/28 20:33:39 UTC

[cassandra] branch trunk updated: generate keyspace names internally instead of abusing tempfile

This is an automated email from the ASF dual-hosted git repository.

brandonwilliams pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 132c01e  generate keyspace names internally instead of abusing tempfile
132c01e is described below

commit 132c01e57011dc611ab8864de1e3e2cbd861acee
Author: Adam Holmberg <ad...@datastax.com>
AuthorDate: Wed Apr 28 14:33:09 2021 -0500

    generate keyspace names internally instead of abusing tempfile
    
    Patch by Adam Holmberg; reviewed by brandonwilliams for CASSANDRA-16639
---
 pylib/cqlshlib/test/cassconnect.py           | 16 +++++++++++--
 pylib/cqlshlib/test/test_cqlsh_completion.py | 35 ++++++++++++++--------------
 2 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/pylib/cqlshlib/test/cassconnect.py b/pylib/cqlshlib/test/cassconnect.py
index c9571f2..7391623 100644
--- a/pylib/cqlshlib/test/cassconnect.py
+++ b/pylib/cqlshlib/test/cassconnect.py
@@ -18,6 +18,8 @@
 import contextlib
 import io
 import os.path
+import random
+import string
 import tempfile
 
 from .basecase import TEST_HOST, TEST_PORT, cql, cqlsh, cqlshlog, policy, quote_name, rundir
@@ -39,9 +41,19 @@ TEST_KEYSPACES_CREATED = []
 def get_keyspace():
     return None if len(TEST_KEYSPACES_CREATED) == 0 else TEST_KEYSPACES_CREATED[-1]
 
+
+_used_ks_names = set()
+
+
 def make_ks_name():
-    # abuse mktemp to get a quick random-ish name
-    return os.path.basename(tempfile.mktemp(prefix='CqlshTests_'))
+    def random_ks():
+        return 'cqlshtests_' + ''.join(random.choice(string.ascii_lowercase) for _ in range(10))
+
+    s = random_ks()
+    while s in _used_ks_names:
+        s = random_ks()
+    _used_ks_names.add(s)
+    return s
 
 def create_keyspace(cursor):
     ksname = make_ks_name().lower()
diff --git a/pylib/cqlshlib/test/test_cqlsh_completion.py b/pylib/cqlshlib/test/test_cqlsh_completion.py
index fd1580a..270110a 100644
--- a/pylib/cqlshlib/test/test_cqlsh_completion.py
+++ b/pylib/cqlshlib/test/test_cqlsh_completion.py
@@ -805,23 +805,24 @@ class TestCqlshCompletion(CqlshCompletionCase):
                                      'aggmax'],
                             other_choices_ok=True)
 
-    def test_complete_in_drop_columnfamily(self):
-        pass
-
-    def test_complete_in_truncate(self):
-        pass
-
-    def test_complete_in_alter_columnfamily(self):
-        pass
-
-    def test_complete_in_use(self):
-        pass
-
-    def test_complete_in_create_index(self):
-        pass
-
-    def test_complete_in_drop_index(self):
-        pass
+    # TODO: CASSANDRA-16640
+    # def test_complete_in_drop_columnfamily(self):
+    #     pass
+    #
+    # def test_complete_in_truncate(self):
+    #     pass
+    #
+    # def test_complete_in_alter_columnfamily(self):
+    #     pass
+    #
+    # def test_complete_in_use(self):
+    #     pass
+    #
+    # def test_complete_in_create_index(self):
+    #     pass
+    #
+    # def test_complete_in_drop_index(self):
+    #     pass
 
     def test_complete_in_alter_keyspace(self):
         self.trycompletions('ALTER KEY', 'SPACE ')

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org