cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tylerho...@apache.org
Subject [1/4] git commit: Fix failing cqlsh formatting tests
Date Tue, 12 Aug 2014 20:19:50 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk 2dfa90e2b -> d2bed56b0


Fix failing cqlsh formatting tests

Patch by Tyler Hobbs; review by Aleksey Yeschenko for CASSANDRA-7703


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

Branch: refs/heads/trunk
Commit: 0edd5ee9812bcc5852433751171c1687948e8bed
Parents: 7ddcf3e
Author: Tyler Hobbs <tyler@datastax.com>
Authored: Tue Aug 12 15:01:49 2014 -0500
Committer: Tyler Hobbs <tyler@datastax.com>
Committed: Tue Aug 12 15:01:49 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                |   1 +
 pylib/cqlshlib/test/test_cqlsh_output.py   | 110 ++++++------------------
 pylib/cqlshlib/test/test_keyspace_init.cql |  34 ++------
 3 files changed, 33 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0edd5ee9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index d42c100..ae88957 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.0.10
+ * (cqlsh) Fix failing cqlsh formatting tests (CASSANDRA-7703)
  * Fix MS expiring map timeout for Paxos messages (CASSANDRA-7752)
  * Do not flush on truncate if durable_writes is false (CASSANDRA-7750)
  * Give CRR a default input_cql Statement (CASSANDRA-7226)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0edd5ee9/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 f89127d..e680cab 100644
--- a/pylib/cqlshlib/test/test_cqlsh_output.py
+++ b/pylib/cqlshlib/test/test_cqlsh_output.py
@@ -21,7 +21,7 @@ from __future__ import with_statement
 
 import re
 from itertools import izip
-from .basecase import (BaseTestCase, cqlshlog, dedent, at_a_time, cql,
+from .basecase import (BaseTestCase, cqlshlog, dedent, at_a_time,
                        TEST_HOST, TEST_PORT)
 from .cassconnect import (get_test_keyspace, testrun_cqlsh, testcall_cqlsh,
                           cassandra_cursor, split_cql_commands, quote_name)
@@ -31,7 +31,9 @@ from .ansi_colors import (ColoredText, lookup_colorcode, lookup_colorname,
 CONTROL_C = '\x03'
 CONTROL_D = '\x04'
 
+
 class TestCqlshOutput(BaseTestCase):
+
     def setUp(self):
         pass
 
@@ -93,33 +95,28 @@ class TestCqlshOutput(BaseTestCase):
             with testrun_cqlsh(tty=True, env={'TERM': termname}) as c:
                 c.send('select * from has_all_types;\n')
                 self.assertNoHasColors(c.read_to_next_prompt())
-                c.send('select * from has_value_encoding_errors;\n')
-                self.assertNoHasColors(c.read_to_next_prompt())
                 c.send('select count(*) from has_all_types;\n')
                 self.assertNoHasColors(c.read_to_next_prompt())
                 c.send('totally invalid cql;\n')
                 self.assertNoHasColors(c.read_to_next_prompt())
 
     def test_no_prompt_or_colors_output(self):
-        # CQL queries and number of lines expected in output:
-        queries = (('select * from has_all_types limit 1;', 7),
-                   ('select * from has_value_encoding_errors limit 1;', 8))
         for termname in ('', 'dumb', 'vt100', 'xterm'):
             cqlshlog.debug('TERM=%r' % termname)
-            for cql, lines_expected in queries:
-                output, result = testcall_cqlsh(prompt=None, env={'TERM': termname},
-                                                tty=False, input=cql + '\n')
-                output = output.splitlines()
-                for line in output:
-                    self.assertNoHasColors(line)
-                    self.assertNotRegexpMatches(line, r'^cqlsh\S*>')
-                self.assertEqual(len(output), lines_expected,
-                                 msg='output: %r' % '\n'.join(output))
-                self.assertEqual(output[0], '')
-                self.assertNicelyFormattedTableHeader(output[1])
-                self.assertNicelyFormattedTableRule(output[2])
-                self.assertNicelyFormattedTableData(output[3])
-                self.assertEqual(output[4].strip(), '')
+            query = 'select * from has_all_types limit 1;'
+            output, result = testcall_cqlsh(prompt=None, env={'TERM': termname},
+                                            tty=False, input=query + '\n')
+            output = output.splitlines()
+            for line in output:
+                self.assertNoHasColors(line)
+                self.assertNotRegexpMatches(line, r'^cqlsh\S*>')
+            self.assertTrue(6 <= len(output) <= 8,
+                            msg='output: %r' % '\n'.join(output))
+            self.assertEqual(output[0], '')
+            self.assertNicelyFormattedTableHeader(output[1])
+            self.assertNicelyFormattedTableRule(output[2])
+            self.assertNicelyFormattedTableData(output[3])
+            self.assertEqual(output[4].strip(), '')
 
     def test_color_output(self):
         for termname in ('xterm', 'unknown-garbage'):
@@ -127,8 +124,6 @@ class TestCqlshOutput(BaseTestCase):
             with testrun_cqlsh(tty=True, env={'TERM': termname}) as c:
                 c.send('select * from has_all_types;\n')
                 self.assertHasColors(c.read_to_next_prompt())
-                c.send('select * from has_value_encoding_errors;\n')
-                self.assertHasColors(c.read_to_next_prompt())
                 c.send('select count(*) from has_all_types;\n')
                 self.assertHasColors(c.read_to_next_prompt())
                 c.send('totally invalid cql;\n')
@@ -438,7 +433,7 @@ class TestCqlshOutput(BaseTestCase):
 
     def test_string_output_ascii(self):
         self.assertCqlverQueriesGiveColoredOutput((
-            ("select * from ascii_with_invalid_and_special_chars where k in (0, 1, 2, 3,
4);", r"""
+            ("select * from ascii_with_special_chars where k in (0, 1, 2, 3);", r"""
              k | val
              M   MMM
             ---+-----------------------------------------------
@@ -449,13 +444,11 @@ class TestCqlshOutput(BaseTestCase):
              G                           YYYYYYmmYYYYYYYYmmmmY
              2 | \x00\x01\x02\x03\x04\x05control chars\x06\x07
              G   mmmmmmmmmmmmmmmmmmmmmmmmYYYYYYYYYYYYYmmmmmmmm
-             3 |                       \xfe\xffbyte order mark 
-             G                         mmmmmmmmYYYYYYYYYYYYYYY
-             4 |                      fake special chars\x00\n
+             3 |                      fake special chars\x00\n
              G                        YYYYYYYYYYYYYYYYYYYYYYYY
 
 
-            (5 rows)
+            (4 rows)
             nnnnnnnn
             """),
         ), cqlver=3)
@@ -516,55 +509,6 @@ class TestCqlshOutput(BaseTestCase):
             """),
         ), cqlver=3)
 
-    def test_colname_decoding_errors(self):
-        # not clear how to achieve this situation in the first place. the
-        # validator works pretty well, and we can't change the comparator
-        # after insertion.
-        #
-        # guess we could monkey-patch cqlsh or python-cql source to
-        # explicitly generate an exception on the deserialization of type X..
-        pass
-
-    def test_colval_decoding_errors(self):
-        self.assertCqlverQueriesGiveColoredOutput((
-            ("select * from has_value_encoding_errors;", r"""
-             pkey | utf8col
-             MMMM   MMMMMMM
-            ------+--------------------
-
-                A | '\x00\xff\x00\xff'
-                Y   RRRRRRRRRRRRRRRRRR
-
-
-            (1 rows)
-            nnnnnnnn
-
-
-            Failed to decode value '\x00\xff\x00\xff' (for column 'utf8col') as text: 'utf8'
codec can't decode byte 0xff in position 1: invalid start byte
-            RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
-            """),
-        ), cqlver=3)
-
-    def test_key_decoding_errors(self):
-        self.assertCqlverQueriesGiveColoredOutput((
-            ("select * from has_key_encoding_errors;", r"""
-             pkey               | col
-             MMMM                 MMM
-            --------------------+----------
-
-             '\x00\xff\x02\x8f' | whatever
-             RRRRRRRRRRRRRRRRRR   YYYYYYYY
-
-
-            (1 rows)
-            nnnnnnnn
-
-
-            Failed to decode value '\x00\xff\x02\x8f' (for column 'pkey') as text: 'utf8'
codec can't decode byte 0xff in position 1: invalid start byte
-            RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR
-            """),
-        ), cqlver=3)
-
     def test_prompt(self):
         with testrun_cqlsh(tty=True, keyspace=None, cqlver=3) as c:
             self.assertEqual(c.output_header.splitlines()[-1], 'cqlsh> ')
@@ -652,19 +596,19 @@ class TestCqlshOutput(BaseTestCase):
               uuidcol uuid,
               varcharcol text,
               varintcol varint,
-              PRIMARY KEY (num)
+              PRIMARY KEY ((num))
             ) WITH
               bloom_filter_fp_chance=0.010000 AND
               caching='KEYS_ONLY' AND
               comment='' AND
-              dclocal_read_repair_chance=0.000000 AND
+              dclocal_read_repair_chance=0.100000 AND
               gc_grace_seconds=864000 AND
               index_interval=128 AND
-              read_repair_chance=0.100000 AND
+              read_repair_chance=0.000000 AND
               replicate_on_write='true' AND
               populate_io_cache_on_flush='false' AND
               default_time_to_live=0 AND
-              speculative_retry='NONE' AND
+              speculative_retry='99.0PERCENTILE' AND
               memtable_flush_period_in_ms=0 AND
               compaction={'class': 'SizeTieredCompactionStrategy'} AND
               compression={'sstable_compression': 'LZ4Compressor'};
@@ -705,7 +649,7 @@ class TestCqlshOutput(BaseTestCase):
                         cfnames = section.group('cfnames')
                         self.assertNotIn('\n\n', cfnames)
                         if ksname == ks:
-                            self.assertIn('ascii_with_invalid_and_special_chars', cfnames)
+                            self.assertIn('ascii_with_special_chars', cfnames)
 
                     self.assertIn('system', ksnames)
                     self.assertIn(quote_name('3.0.0', ks), ksnames)
@@ -721,7 +665,6 @@ class TestCqlshOutput(BaseTestCase):
                     self.assertEqual(output[0], '\n')
                     self.assertEqual(output[-1], '\n')
                     self.assertNotIn('Keyspace %s' % quote_name('3.0.0', ks), output)
-                    self.assertIn('has_value_encoding_errors', output)
                     self.assertIn('undefined_values_table', output)
 
     def test_describe_cluster_output(self):
@@ -801,8 +744,7 @@ class TestCqlshOutput(BaseTestCase):
 
     def test_help_types(self):
         with testrun_cqlsh(tty=True) as c:
-            output = c.cmd_and_response('help types')
-
+            c.cmd_and_response('help types')
 
     def test_help(self):
         pass

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0edd5ee9/pylib/cqlshlib/test/test_keyspace_init.cql
----------------------------------------------------------------------
diff --git a/pylib/cqlshlib/test/test_keyspace_init.cql b/pylib/cqlshlib/test/test_keyspace_init.cql
index e92d5d0..f63811f 100644
--- a/pylib/cqlshlib/test/test_keyspace_init.cql
+++ b/pylib/cqlshlib/test/test_keyspace_init.cql
@@ -52,24 +52,6 @@ VALUES (4, blobAsInt(0x), '', blobAsBigint(0x), 0x, blobAsBoolean(0x),
blobAsDec
         blobAsVarint(0x));
 
 
-CREATE TABLE has_value_encoding_errors (
-    pkey ascii PRIMARY KEY,
-    utf8col blob
-);
-
-INSERT INTO has_value_encoding_errors (pkey, utf8col) VALUES ('A', 0x00ff00ff);
-ALTER TABLE has_value_encoding_errors ALTER utf8col TYPE text;
-
-CREATE TABLE has_key_encoding_errors (
-    pkey blob PRIMARY KEY,
-    col text
-);
-
-INSERT INTO has_key_encoding_errors (pkey, col) VALUES (0x00ff028f, 'whatever');
-ALTER TABLE has_key_encoding_errors ALTER pkey TYPE text;
-
-
-
 CREATE TABLE empty_table (
     lonelykey float primary key,
     lonelycol text
@@ -130,23 +112,19 @@ INSERT INTO undefined_values_table (k, c) VALUES ('k2', 'c2');
 
 
 
-CREATE TABLE ascii_with_invalid_and_special_chars (
+CREATE TABLE ascii_with_special_chars (
     k int PRIMARY KEY,
-    val blob
+    val ascii
 );
 
 -- "newline:\n"
-INSERT INTO ascii_with_invalid_and_special_chars (k, val) VALUES (0, 0x6e65776c696e653a0a);
+INSERT INTO ascii_with_special_chars (k, val) VALUES (0, blobAsAscii(0x6e65776c696e653a0a));
 -- "return\rand null\0!"
-INSERT INTO ascii_with_invalid_and_special_chars (k, val) VALUES (1, 0x72657475726e0d616e64206e756c6c0021);
+INSERT INTO ascii_with_special_chars (k, val) VALUES (1, blobAsAscii(0x72657475726e0d616e64206e756c6c0021));
 -- "\x00\x01\x02\x03\x04\x05control chars\x06\x07"
-INSERT INTO ascii_with_invalid_and_special_chars (k, val) VALUES (2, 0x000102030405636f6e74726f6c2063686172730607);
--- "\xfe\xffbyte order mark"
-INSERT INTO ascii_with_invalid_and_special_chars (k, val) VALUES (3, 0xfeff62797465206f72646572206d61726b);
+INSERT INTO ascii_with_special_chars (k, val) VALUES (2, blobAsAscii(0x000102030405636f6e74726f6c2063686172730607));
 -- "fake special chars\\x00\\n"
-INSERT INTO ascii_with_invalid_and_special_chars (k, val) VALUES (4, 0x66616b65207370656369616c2063686172735c7830305c6e);
-
-ALTER TABLE ascii_with_invalid_and_special_chars ALTER val TYPE ascii;
+INSERT INTO ascii_with_special_chars (k, val) VALUES (3, blobAsAscii(0x66616b65207370656369616c2063686172735c7830305c6e));
 
 
 


Mime
View raw message