cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stefa...@apache.org
Subject [02/10] cassandra git commit: Fixed cqlshlib.test.remove_test_db
Date Wed, 20 Jul 2016 02:03:05 GMT
Fixed cqlshlib.test.remove_test_db

patch by Stefania Alborghetti; reviewed by Philip Thompson for CASSANDRA-12214


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e8186fe3
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e8186fe3
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e8186fe3

Branch: refs/heads/cassandra-3.0
Commit: e8186fe390073f5d7ea11057c5bc842db86d95d2
Parents: f0d1d75
Author: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Authored: Tue Jul 19 11:15:46 2016 +0800
Committer: Stefania Alborghetti <stefania.alborghetti@datastax.com>
Committed: Wed Jul 20 09:54:53 2016 +0800

----------------------------------------------------------------------
 CHANGES.txt                              |  1 +
 pylib/cqlshlib/test/__init__.py          |  6 +++---
 pylib/cqlshlib/test/cassconnect.py       | 22 +++++++++++-----------
 pylib/cqlshlib/test/test_cqlsh_output.py | 14 +++++++-------
 4 files changed, 22 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8186fe3/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 837c3fb..ffd92b5 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.2.8
+ * Fixed cqlshlib.test.remove_test_db (CASSANDRA-12214)
  * Synchronize ThriftServer::stop() (CASSANDRA-12105)
  * Use dedicated thread for JMX notifications (CASSANDRA-12146)
  * NPE when trying to remove purgable tombstones from result (CASSANDRA-12143)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8186fe3/pylib/cqlshlib/test/__init__.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/test/__init__.py b/pylib/cqlshlib/test/__init__.py
index 31f66f3..ba8f373 100644
--- a/pylib/cqlshlib/test/__init__.py
+++ b/pylib/cqlshlib/test/__init__.py
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-from .cassconnect import create_test_db, remove_test_db
+from .cassconnect import create_db, remove_db
 
-setUp = create_test_db
-tearDown = remove_test_db
+setUp = create_db
+tearDown = remove_db

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8186fe3/pylib/cqlshlib/test/cassconnect.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/test/cassconnect.py b/pylib/cqlshlib/test/cassconnect.py
index 94910a6..4a1311e 100644
--- a/pylib/cqlshlib/test/cassconnect.py
+++ b/pylib/cqlshlib/test/cassconnect.py
@@ -37,15 +37,15 @@ def get_cassandra_cursor(cql_version=cqlsh.DEFAULT_CQLVER):
 
 TEST_KEYSPACES_CREATED = []
 
-def get_test_keyspace():
-    return TEST_KEYSPACES_CREATED[-1]
+def get_keyspace():
+    return None if len(TEST_KEYSPACES_CREATED) == 0 else TEST_KEYSPACES_CREATED[-1]
 
-def make_test_ks_name():
+def make_ks_name():
     # abuse mktemp to get a quick random-ish name
     return os.path.basename(tempfile.mktemp(prefix='CqlshTests_'))
 
-def create_test_keyspace(cursor):
-    ksname = make_test_ks_name()
+def create_keyspace(cursor):
+    ksname = make_ks_name()
     qksname = quote_name(ksname)
     cursor.execute('''
         CREATE KEYSPACE %s WITH replication =
@@ -72,13 +72,13 @@ def execute_cql_file(cursor, fname):
     with open(fname) as f:
         return execute_cql_commands(cursor, f.read())
 
-def create_test_db():
+def create_db():
     with cassandra_cursor(ks=None) as c:
-        k = create_test_keyspace(c)
+        k = create_keyspace(c)
         execute_cql_file(c, test_keyspace_init)
     return k
 
-def remove_test_db():
+def remove_db():
     with cassandra_cursor(ks=None) as c:
         c.execute('DROP KEYSPACE %s' % quote_name(TEST_KEYSPACES_CREATED.pop(-1)))
 
@@ -112,7 +112,7 @@ def cassandra_cursor(cql_version=None, ks=''):
     """
 
     if ks == '':
-        ks = get_test_keyspace()
+        ks = get_keyspace()
     conn = get_cassandra_connection(cql_version=cql_version)
     try:
         c = conn.connect(ks)
@@ -131,10 +131,10 @@ def testrun_cqlsh(keyspace=DEFAULTVAL, **kwargs):
     # use a positive default sentinel so that keyspace=None can be used
     # to override the default behavior
     if keyspace is DEFAULTVAL:
-        keyspace = get_test_keyspace()
+        keyspace = get_keyspace()
     return run_cqlsh(keyspace=keyspace, **kwargs)
 
 def testcall_cqlsh(keyspace=None, **kwargs):
     if keyspace is None:
-        keyspace = get_test_keyspace()
+        keyspace = get_keyspace()
     return call_cqlsh(keyspace=keyspace, **kwargs)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8186fe3/pylib/cqlshlib/test/test_cqlsh_output.py
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/test/test_cqlsh_output.py b/pylib/cqlshlib/test/test_cqlsh_output.py
index fdc562f..60699f3 100644
--- a/pylib/cqlshlib/test/test_cqlsh_output.py
+++ b/pylib/cqlshlib/test/test_cqlsh_output.py
@@ -23,7 +23,7 @@ import re
 from itertools import izip
 from .basecase import (BaseTestCase, cqlshlog, dedent, at_a_time, cqlsh,
                        TEST_HOST, TEST_PORT)
-from .cassconnect import (get_test_keyspace, testrun_cqlsh, testcall_cqlsh,
+from .cassconnect import (get_keyspace, testrun_cqlsh, testcall_cqlsh,
                           cassandra_cursor, split_cql_commands, quote_name)
 from .ansi_colors import (ColoredText, lookup_colorcode, lookup_colorname,
                           lookup_colorletter, ansi_seq)
@@ -534,10 +534,10 @@ class TestCqlshOutput(BaseTestCase):
             output = c.read_to_next_prompt().replace('\r\n', '\n')
             self.assertTrue(output.endswith('cqlsh> '))
 
-            cmd = "USE \"%s\";\n" % get_test_keyspace().replace('"', '""')
+            cmd = "USE \"%s\";\n" % get_keyspace().replace('"', '""')
             c.send(cmd)
             output = c.read_to_next_prompt().replace('\r\n', '\n')
-            self.assertTrue(output.endswith('cqlsh:%s> ' % (get_test_keyspace())))
+            self.assertTrue(output.endswith('cqlsh:%s> ' % (get_keyspace())))
 
             c.send('use system;\n')
             output = c.read_to_next_prompt().replace('\r\n', '\n')
@@ -561,7 +561,7 @@ class TestCqlshOutput(BaseTestCase):
     def test_describe_keyspace_output(self):
         fullcqlver = cqlsh.DEFAULT_CQLVER
         with testrun_cqlsh(tty=True, cqlver=fullcqlver) as c:
-            ks = get_test_keyspace()
+            ks = get_keyspace()
             qks = quote_name(ks)
             for cmd in ('describe keyspace', 'desc keyspace'):
                 for givename in ('system', '', qks):
@@ -632,7 +632,7 @@ class TestCqlshOutput(BaseTestCase):
                 AND read_repair_chance = 0.0
                 AND speculative_retry = '99.0PERCENTILE';
 
-        """ % quote_name(get_test_keyspace()))
+        """ % quote_name(get_keyspace()))
 
         with testrun_cqlsh(tty=True, cqlver=cqlsh.DEFAULT_CQLVER) as c:
             for cmdword in ('describe table', 'desc columnfamily'):
@@ -650,7 +650,7 @@ class TestCqlshOutput(BaseTestCase):
             \n
         '''
 
-        ks = get_test_keyspace()
+        ks = get_keyspace()
 
         with testrun_cqlsh(tty=True, keyspace=None, cqlver=cqlsh.DEFAULT_CQLVER) as c:
 
@@ -711,7 +711,7 @@ class TestCqlshOutput(BaseTestCase):
                 self.assertNoHasColors(output)
                 self.assertRegexpMatches(output, output_re + '$')
 
-            c.send('USE %s;\n' % quote_name(get_test_keyspace()))
+            c.send('USE %s;\n' % quote_name(get_keyspace()))
             c.read_to_next_prompt()
 
             for semicolon in ('', ';'):


Mime
View raw message