Fix cqlshlib tests

patch by Jim Witschey; reviewed by Stefania Alborghetti for
CASSANDRA-10289
This commit is contained in:
Jim Witschey 2015-10-01 19:24:48 -07:00 committed by Aleksey Yeschenko
parent ae9b7e0522
commit f3cd3ed7bb
7 changed files with 149 additions and 145 deletions

View File

@ -31,7 +31,7 @@ except ImportError:
import unittest
rundir = dirname(__file__)
path_to_cqlsh = normpath(join(rundir, '..', '..', '..', 'bin', 'cqlsh'))
path_to_cqlsh = normpath(join(rundir, '..', '..', '..', 'bin', 'cqlsh.py'))
# symlink a ".py" file to cqlsh main script, so we can load it as a module
modulepath = join(rundir, 'cqlsh.py')

View File

@ -21,6 +21,7 @@ import tempfile
import os.path
from .basecase import cql, cqlsh, cqlshlog, TEST_HOST, TEST_PORT, rundir, policy
from .run_cqlsh import run_cqlsh, call_cqlsh
from cassandra.metadata import maybe_escape_name
test_keyspace_init = os.path.join(rundir, 'test_keyspace_init.cql')
@ -126,7 +127,7 @@ def cql_rule_set():
return cqlsh.cql3handling.CqlRuleSet
def quote_name(name):
return cql_rule_set().maybe_escape_name(name)
return maybe_escape_name(name)
class DEFAULTVAL: pass

View File

@ -126,7 +126,7 @@ class ProcRunner:
stderr = subprocess.STDOUT
cqlshlog.info("Spawning %r subprocess with args: %r and env: %r"
% (self.exe_path, self.args, self.env))
self.proc = subprocess.Popen((self.exe_path,) + tuple(self.args),
self.proc = subprocess.Popen(('python', self.exe_path,) + tuple(self.args),
env=self.env, preexec_fn=preexec,
stdin=stdin, stdout=stdout, stderr=stderr,
close_fds=False)

View File

@ -64,8 +64,8 @@ class TestCqlParsing(TestCase):
[parsed] = CqlRuleSet.cql_parse('INSERT INTO ks.test')
self.assertSequenceEqual(parsed.matched, [])
self.assertSequenceEqual(tokens_with_types(parsed.remainder),
[('INSERT', 'K_INSERT'),
('INTO', 'K_INTO'),
[('INSERT', 'identifier'),
('INTO', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('test', 'identifier')])
@ -73,8 +73,8 @@ class TestCqlParsing(TestCase):
def test_parse_select(self):
parsed = parse_cqlsh_statements('SELECT FROM ks.tab;')
self.assertSequenceEqual(tokens_with_types(parsed),
[('SELECT', 'K_SELECT'),
('FROM', 'K_FROM'),
[('SELECT', 'identifier'),
('FROM', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
@ -82,18 +82,18 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements('SELECT FROM "MyTable";')
self.assertSequenceEqual(tokens_with_types(parsed),
[('SELECT', 'K_SELECT'),
('FROM', 'K_FROM'),
[('SELECT', 'identifier'),
('FROM', 'identifier'),
('"MyTable"', 'quotedName'),
(';', 'endtoken')])
parsed = parse_cqlsh_statements(
'SELECT FROM tab WHERE foo = 3;')
self.assertSequenceEqual(tokens_with_types(parsed),
[('SELECT', 'K_SELECT'),
('FROM', 'K_FROM'),
[('SELECT', 'identifier'),
('FROM', 'identifier'),
('tab', 'identifier'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('foo', 'identifier'),
('=', 'op'),
('3', 'wholenumber'),
@ -102,28 +102,28 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
'SELECT FROM tab ORDER BY event_id DESC LIMIT 1000')
self.assertSequenceEqual(tokens_with_types(parsed),
[('SELECT', 'K_SELECT'),
('FROM', 'K_FROM'),
[('SELECT', 'identifier'),
('FROM', 'identifier'),
('tab', 'identifier'),
('ORDER', 'K_ORDER'),
('BY', 'K_BY'),
('ORDER', 'identifier'),
('BY', 'identifier'),
('event_id', 'identifier'),
('DESC', 'K_DESC'),
('LIMIT', 'K_LIMIT'),
('DESC', 'identifier'),
('LIMIT', 'identifier'),
('1000', 'wholenumber')])
parsed = parse_cqlsh_statements(
'SELECT FROM tab WHERE clustering_column > 200 '
'AND clustering_column < 400 ALLOW FILTERING')
self.assertSequenceEqual(tokens_with_types(parsed),
[('SELECT', 'K_SELECT'),
('FROM', 'K_FROM'),
[('SELECT', 'identifier'),
('FROM', 'identifier'),
('tab', 'identifier'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('clustering_column', 'identifier'),
('>', 'cmp'),
('200', 'wholenumber'),
('AND', 'K_AND'),
('AND', 'identifier'),
('clustering_column', 'identifier'),
('<', 'cmp'),
('400', 'wholenumber'),
@ -134,13 +134,13 @@ class TestCqlParsing(TestCase):
def test_parse_insert(self):
parsed = parse_cqlsh_statements('INSERT INTO mytable (x) VALUES (2);')
self.assertSequenceEqual(tokens_with_types(parsed),
[('INSERT', 'K_INSERT'),
('INTO', 'K_INTO'),
[('INSERT', 'identifier'),
('INTO', 'identifier'),
('mytable', 'identifier'),
('(', 'op'),
('x', 'identifier'),
(')', 'op'),
('VALUES', 'K_VALUES'),
('VALUES', 'identifier'),
('(', 'op'),
('2', 'wholenumber'),
(')', 'op'),
@ -149,15 +149,15 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"INSERT INTO mytable (x, y) VALUES (2, 'eggs');")
self.assertSequenceEqual(tokens_with_types(parsed),
[('INSERT', 'K_INSERT'),
('INTO', 'K_INTO'),
[('INSERT', 'identifier'),
('INTO', 'identifier'),
('mytable', 'identifier'),
('(', 'op'),
('x', 'identifier'),
(',', 'op'),
('y', 'identifier'),
(')', 'op'),
('VALUES', 'K_VALUES'),
('VALUES', 'identifier'),
('(', 'op'),
('2', 'wholenumber'),
(',', 'op'),
@ -168,15 +168,15 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"INSERT INTO mytable (x, y) VALUES (2, 'eggs');")
self.assertSequenceEqual(tokens_with_types(parsed),
[('INSERT', 'K_INSERT'),
('INTO', 'K_INTO'),
[('INSERT', 'identifier'),
('INTO', 'identifier'),
('mytable', 'identifier'),
('(', 'op'),
('x', 'identifier'),
(',', 'op'),
('y', 'identifier'),
(')', 'op'),
('VALUES', 'K_VALUES'),
('VALUES', 'identifier'),
('(', 'op'),
('2', 'wholenumber'),
(',', 'op'),
@ -189,18 +189,18 @@ class TestCqlParsing(TestCase):
"(7ee251da-af52-49a4-97f4-3f07e406c7a7) "
"USING TTL 86400;")
self.assertSequenceEqual(tokens_with_types(parsed),
[('INSERT', 'K_INSERT'),
('INTO', 'K_INTO'),
[('INSERT', 'identifier'),
('INTO', 'identifier'),
('mytable', 'identifier'),
('(', 'op'),
('ids', 'identifier'),
(')', 'op'),
('VALUES', 'K_VALUES'),
('VALUES', 'identifier'),
('(', 'op'),
('7ee251da-af52-49a4-97f4-3f07e406c7a7', 'uuid'),
(')', 'op'),
('USING', 'K_USING'),
('TTL', 'K_TTL'),
('USING', 'identifier'),
('TTL', 'identifier'),
('86400', 'wholenumber'),
(';', 'endtoken')])
@ -208,21 +208,21 @@ class TestCqlParsing(TestCase):
"INSERT INTO test_table (username) VALUES ('Albert') "
"USING TIMESTAMP 1240003134 AND TTL 600;")
self.assertSequenceEqual(tokens_with_types(parsed),
[('INSERT', 'K_INSERT'),
('INTO', 'K_INTO'),
[('INSERT', 'identifier'),
('INTO', 'identifier'),
('test_table', 'identifier'),
('(', 'op'),
('username', 'identifier'),
(')', 'op'),
('VALUES', 'K_VALUES'),
('VALUES', 'identifier'),
('(', 'op'),
("'Albert'", 'quotedStringLiteral'),
(')', 'op'),
('USING', 'K_USING'),
('TIMESTAMP', 'K_TIMESTAMP'),
('USING', 'identifier'),
('TIMESTAMP', 'identifier'),
('1240003134', 'wholenumber'),
('AND', 'K_AND'),
('TTL', 'K_TTL'),
('AND', 'identifier'),
('TTL', 'identifier'),
('600', 'wholenumber'),
(';', 'endtoken')])
@ -230,13 +230,13 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"UPDATE tab SET x = 15 WHERE y = 'eggs';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('=', 'op'),
("'eggs'", 'quotedStringLiteral'),
@ -245,16 +245,16 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"UPDATE tab USING TTL 432000 SET x = 15 WHERE y = 'eggs';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('USING', 'K_USING'),
('TTL', 'K_TTL'),
('USING', 'identifier'),
('TTL', 'identifier'),
('432000', 'wholenumber'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('=', 'op'),
("'eggs'", 'quotedStringLiteral'),
@ -264,9 +264,9 @@ class TestCqlParsing(TestCase):
"UPDATE tab SET x = 15, y = 'sausage' "
"WHERE y = 'eggs';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
@ -274,7 +274,7 @@ class TestCqlParsing(TestCase):
('y', 'identifier'),
('=', 'op'),
("'sausage'", 'quotedStringLiteral'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('=', 'op'),
("'eggs'", 'quotedStringLiteral'),
@ -284,15 +284,15 @@ class TestCqlParsing(TestCase):
"UPDATE tab SET x = 15 "
"WHERE y IN ('eggs', 'sausage', 'spam');")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('IN', 'K_IN'),
('IN', 'identifier'),
('(', 'op'),
("'eggs'", 'quotedStringLiteral'),
(',', 'op'),
@ -306,17 +306,17 @@ class TestCqlParsing(TestCase):
"UPDATE tab SET x = 15 "
"WHERE y = 'spam' if z = 'sausage';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('=', 'op'),
("'spam'", 'quotedStringLiteral'),
('if', 'K_IF'),
('if', 'identifier'),
('z', 'identifier'),
('=', 'op'),
("'sausage'", 'quotedStringLiteral'),
@ -326,21 +326,21 @@ class TestCqlParsing(TestCase):
"UPDATE tab SET x = 15 WHERE y = 'spam' "
"if z = 'sausage' AND w = 'spam';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('=', 'op'),
("'spam'", 'quotedStringLiteral'),
('if', 'K_IF'),
('if', 'identifier'),
('z', 'identifier'),
('=', 'op'),
("'sausage'", 'quotedStringLiteral'),
('AND', 'K_AND'),
('AND', 'identifier'),
('w', 'identifier'),
('=', 'op'),
("'spam'", 'quotedStringLiteral'),
@ -349,27 +349,27 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"UPDATE tab SET x = 15 WHERE y = 'spam' IF EXISTS")
self.assertSequenceEqual(tokens_with_types(parsed),
[('UPDATE', 'K_UPDATE'),
[('UPDATE', 'identifier'),
('tab', 'identifier'),
('SET', 'K_SET'),
('SET', 'identifier'),
('x', 'identifier'),
('=', 'op'),
('15', 'wholenumber'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('y', 'identifier'),
('=', 'op'),
("'spam'", 'quotedStringLiteral'),
('IF', 'K_IF'),
('IF', 'identifier'),
('EXISTS', 'identifier')])
def test_parse_delete(self):
parsed = parse_cqlsh_statements(
"DELETE FROM songs WHERE songid = 444;")
self.assertSequenceEqual(tokens_with_types(parsed),
[('DELETE', 'K_DELETE'),
('FROM', 'K_FROM'),
[('DELETE', 'identifier'),
('FROM', 'identifier'),
('songs', 'identifier'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('songid', 'identifier'),
('=', 'op'),
('444', 'wholenumber'),
@ -379,12 +379,12 @@ class TestCqlParsing(TestCase):
"DELETE FROM songs WHERE name IN "
"('Yellow Submarine', 'Eleanor Rigby');")
self.assertSequenceEqual(tokens_with_types(parsed),
[('DELETE', 'K_DELETE'),
('FROM', 'K_FROM'),
[('DELETE', 'identifier'),
('FROM', 'identifier'),
('songs', 'identifier'),
('WHERE', 'K_WHERE'),
('WHERE', 'identifier'),
('name', 'identifier'),
('IN', 'K_IN'),
('IN', 'identifier'),
('(', 'op'),
("'Yellow Submarine'", 'quotedStringLiteral'),
(',', 'op'),
@ -395,14 +395,14 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"DELETE task_map ['2014-12-25'] from tasks where user_id = 'Santa';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('DELETE', 'K_DELETE'),
[('DELETE', 'identifier'),
('task_map', 'identifier'),
('[', 'brackets'),
("'2014-12-25'", 'quotedStringLiteral'),
(']', 'brackets'),
('from', 'K_FROM'),
('from', 'identifier'),
('tasks', 'identifier'),
('where', 'K_WHERE'),
('where', 'identifier'),
('user_id', 'identifier'),
('=', 'op'),
("'Santa'", 'quotedStringLiteral'),
@ -411,14 +411,14 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
"DELETE my_list[0] from lists where user_id = 'Jim';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('DELETE', 'K_DELETE'),
[('DELETE', 'identifier'),
('my_list', 'identifier'),
('[', 'brackets'),
('0', 'wholenumber'),
(']', 'brackets'),
('from', 'K_FROM'),
('from', 'identifier'),
('lists', 'identifier'),
('where', 'K_WHERE'),
('where', 'identifier'),
('user_id', 'identifier'),
('=', 'op'),
("'Jim'", 'quotedStringLiteral'),
@ -432,10 +432,10 @@ class TestCqlParsing(TestCase):
"CREATE KEYSPACE ks WITH REPLICATION = "
"{'class': 'SimpleStrategy', 'replication_factor': 1};")
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('KEYSPACE', 'K_KEYSPACE'),
[('CREATE', 'identifier'),
('KEYSPACE', 'identifier'),
('ks', 'identifier'),
('WITH', 'K_WITH'),
('WITH', 'identifier'),
('REPLICATION', 'identifier'),
('=', 'op'),
('{', 'brackets'),
@ -453,10 +453,10 @@ class TestCqlParsing(TestCase):
'CREATE KEYSPACE "Cql_test_KS" WITH REPLICATION = '
"{'class': 'NetworkTopologyStrategy', 'dc1' : 3, 'dc2': 2};")
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('KEYSPACE', 'K_KEYSPACE'),
[('CREATE', 'identifier'),
('KEYSPACE', 'identifier'),
('"Cql_test_KS"', 'quotedName'),
('WITH', 'K_WITH'),
('WITH', 'identifier'),
('REPLICATION', 'identifier'),
('=', 'op'),
('{', 'brackets'),
@ -480,10 +480,10 @@ class TestCqlParsing(TestCase):
"{'class': 'NetworkTopologyStrategy', 'dc1': 3} AND "
"DURABLE_WRITES = false;")
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('KEYSPACE', 'K_KEYSPACE'),
[('CREATE', 'identifier'),
('KEYSPACE', 'identifier'),
('ks', 'identifier'),
('WITH', 'K_WITH'),
('WITH', 'identifier'),
('REPLICATION', 'identifier'),
('=', 'op'),
('{', 'brackets'),
@ -496,7 +496,7 @@ class TestCqlParsing(TestCase):
(':', 'colon'),
('3', 'wholenumber'),
('}', 'brackets'),
('AND', 'K_AND'),
('AND', 'identifier'),
# 'DURABLE_WRITES' is not a keyword
('DURABLE_WRITES', 'identifier'),
('=', 'op'),
@ -507,25 +507,25 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
'DROP KEYSPACE ks;')
self.assertSequenceEqual(tokens_with_types(parsed),
[('DROP', 'K_DROP'),
('KEYSPACE', 'K_KEYSPACE'),
[('DROP', 'identifier'),
('KEYSPACE', 'identifier'),
('ks', 'identifier'),
(';', 'endtoken')])
parsed = parse_cqlsh_statements(
'DROP SCHEMA ks;')
self.assertSequenceEqual(tokens_with_types(parsed),
[('DROP', 'K_DROP'),
('SCHEMA', 'K_SCHEMA'),
[('DROP', 'identifier'),
('SCHEMA', 'identifier'),
('ks', 'identifier'),
(';', 'endtoken')])
parsed = parse_cqlsh_statements(
'DROP KEYSPACE IF EXISTS "My_ks";')
self.assertSequenceEqual(tokens_with_types(parsed),
[('DROP', 'K_DROP'),
('KEYSPACE', 'K_KEYSPACE'),
('IF', 'K_IF'),
[('DROP', 'identifier'),
('KEYSPACE', 'identifier'),
('IF', 'identifier'),
('EXISTS', 'identifier'),
('"My_ks"', 'quotedName'),
(';', 'endtoken')])
@ -549,43 +549,43 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
'CREATE INDEX idx ON ks.tab (i);')
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('INDEX', 'K_INDEX'),
(('CREATE', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
('(', 'op'),
('i', 'identifier'),
(')', 'op'),
(';', 'endtoken')])
(';', 'endtoken')))
parsed = parse_cqlsh_statements(
'CREATE INDEX idx ON ks.tab (i) IF NOT EXISTS;')
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('INDEX', 'K_INDEX'),
(('CREATE', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
('(', 'op'),
('i', 'identifier'),
(')', 'op'),
('IF', 'K_IF'),
('NOT', 'K_NOT'),
('IF', 'identifier'),
('NOT', 'identifier'),
('EXISTS', 'identifier'),
(';', 'endtoken')])
(';', 'endtoken')))
parsed = parse_cqlsh_statements(
'CREATE INDEX idx ON tab (KEYS(i));')
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('INDEX', 'K_INDEX'),
(('CREATE', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('tab', 'identifier'),
('(', 'op'),
('KEYS', 'identifier'),
@ -593,15 +593,15 @@ class TestCqlParsing(TestCase):
('i', 'identifier'),
(')', 'op'),
(')', 'op'),
(';', 'endtoken')])
(';', 'endtoken')))
parsed = parse_cqlsh_statements(
'CREATE INDEX idx ON ks.tab FULL(i);')
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('INDEX', 'K_INDEX'),
[('CREATE', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
@ -614,11 +614,11 @@ class TestCqlParsing(TestCase):
parsed = parse_cqlsh_statements(
'CREATE CUSTOM INDEX idx ON ks.tab (i);')
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('CUSTOM', 'K_CUSTOM'),
('INDEX', 'K_INDEX'),
[('CREATE', 'identifier'),
('CUSTOM', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
@ -631,17 +631,17 @@ class TestCqlParsing(TestCase):
"CREATE INDEX idx ON ks.tab (i) USING "
"'org.custom.index.MyIndexClass';")
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('INDEX', 'K_INDEX'),
[('CREATE', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
('(', 'op'),
('i', 'identifier'),
(')', 'op'),
('USING', 'K_USING'),
('USING', 'identifier'),
("'org.custom.index.MyIndexClass'",
'quotedStringLiteral'),
(';', 'endtoken')])
@ -650,17 +650,17 @@ class TestCqlParsing(TestCase):
"CREATE INDEX idx ON ks.tab (i) WITH OPTIONS = "
"{'storage': '/mnt/ssd/indexes/'};")
self.assertSequenceEqual(tokens_with_types(parsed),
[('CREATE', 'K_CREATE'),
('INDEX', 'K_INDEX'),
[('CREATE', 'identifier'),
('INDEX', 'identifier'),
('idx', 'identifier'),
('ON', 'K_ON'),
('ON', 'identifier'),
('ks', 'identifier'),
('.', 'op'),
('tab', 'identifier'),
('(', 'op'),
('i', 'identifier'),
(')', 'op'),
('WITH', 'K_WITH'),
('WITH', 'identifier'),
('OPTIONS', 'identifier'),
('=', 'op'),
('{', 'brackets'),

View File

@ -145,7 +145,7 @@ class TestCqlshCompletion(CqlshCompletionCase):
'COPY', 'CREATE', 'DEBUG', 'DELETE', 'DESC', 'DESCRIBE',
'DROP', 'GRANT', 'HELP', 'INSERT', 'LIST', 'LOGIN', 'PAGING', 'REVOKE',
'SELECT', 'SHOW', 'SOURCE', 'TRACING', 'EXPAND', 'SERIAL', 'TRUNCATE',
'UPDATE', 'USE', 'exit', 'quit'))
'UPDATE', 'USE', 'exit', 'quit', 'CLEAR', 'CLS'))
def test_complete_command_words(self):
self.trycompletions('alt', '\b\b\bALTER ')
@ -231,7 +231,8 @@ class TestCqlshCompletion(CqlshCompletionCase):
'CREATE', 'DEBUG', 'DELETE', 'DESC', 'DESCRIBE', 'DROP',
'EXPAND', 'GRANT', 'HELP', 'INSERT', 'LIST', 'LOGIN', 'PAGING',
'REVOKE', 'SELECT', 'SHOW', 'SOURCE', 'SERIAL', 'TRACING',
'TRUNCATE', 'UPDATE', 'USE', 'exit', 'quit'])
'TRUNCATE', 'UPDATE', 'USE', 'exit', 'quit',
'CLEAR', 'CLS'])
self.trycompletions(
("INSERT INTO twenty_rows_composite_table (a, b, c) "
@ -401,6 +402,8 @@ class TestCqlshCompletion(CqlshCompletionCase):
'twenty_rows_composite_table',
'utf8_with_special_chars',
'system_traces.', 'songs',
'system_auth.', 'system_distributed.',
'system_schema.','system_traces.',
'"' + self.cqlsh.keyspace + '".'],
other_choices_ok=True)
self.trycompletions('DELETE FROM twenty_rows_composite_table ',
@ -509,9 +512,6 @@ class TestCqlshCompletion(CqlshCompletionCase):
def test_complete_in_string_literals(self):
# would be great if we could get a space after this sort of completion,
# but readline really wants to make things difficult for us
self.trycompletions('insert into system."Index', 'Info"')
self.trycompletions('USE "', choices=('system', self.cqlsh.keyspace),
other_choices_ok=True)
self.trycompletions("create keyspace blah with replication = {'class': 'Sim",
"pleStrategy'")
@ -520,7 +520,7 @@ class TestCqlshCompletion(CqlshCompletionCase):
self.trycompletions('DROP ',
choices=['AGGREGATE', 'COLUMNFAMILY', 'FUNCTION',
'INDEX', 'KEYSPACE', 'ROLE', 'TABLE',
'TRIGGER', 'TYPE', 'USER'])
'TRIGGER', 'TYPE', 'USER', 'MATERIALIZED'])
def test_complete_in_drop_keyspace(self):
self.trycompletions('DROP K', immediate='EYSPACE ')
@ -634,7 +634,8 @@ class TestCqlshCompletion(CqlshCompletionCase):
'min_sstable_size', 'min_threshold',
'tombstone_compaction_interval',
'tombstone_threshold',
'unchecked_tombstone_compaction', ])
'unchecked_tombstone_compaction',
'only_purge_repaired_tombstones'])
self.trycompletions(prefix + " new_table (col_a int PRIMARY KEY) WITH compaction = "
+ "{'class': 'SizeTieredCompactionStrategy'}",
choices=[';', 'AND'])
@ -654,7 +655,8 @@ class TestCqlshCompletion(CqlshCompletionCase):
choices=['base_time_seconds', 'max_sstable_age_days',
'timestamp_resolution', 'min_threshold', 'class', 'max_threshold',
'tombstone_compaction_interval', 'tombstone_threshold',
'enabled', 'unchecked_tombstone_compaction'])
'enabled', 'unchecked_tombstone_compaction',
'only_purge_repaired_tombstones'])
def test_complete_in_create_columnfamily(self):
self.trycompletions('CREATE C', choices=['COLUMNFAMILY', 'CUSTOM'])

View File

@ -176,7 +176,7 @@ class TestCqlshOutput(BaseTestCase):
MMMMM
-------
10
20
GG
@ -610,10 +610,11 @@ class TestCqlshOutput(BaseTestCase):
varcharcol text,
varintcol varint
) WITH bloom_filter_fp_chance = 0.01
AND caching = '{"keys":"ALL", "rows_per_partition":"NONE"}'
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
AND comment = ''
AND compaction = {'min_threshold': '4', 'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32'}
AND compression = {'sstable_compression': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
AND crc_check_chance = 1.0
AND dclocal_read_repair_chance = 0.1
AND default_time_to_live = 0
AND gc_grace_seconds = 864000
@ -621,7 +622,7 @@ class TestCqlshOutput(BaseTestCase):
AND memtable_flush_period_in_ms = 0
AND min_index_interval = 128
AND read_repair_chance = 0.0
AND speculative_retry = '99.0PERCENTILE';
AND speculative_retry = '99PERCENTILE';
""" % quote_name(get_test_keyspace()))
@ -630,7 +631,7 @@ class TestCqlshOutput(BaseTestCase):
for semicolon in (';', ''):
output = c.cmd_and_response('%s has_all_types%s' % (cmdword, semicolon))
self.assertNoHasColors(output)
self.assertEqual(output, table_desc3)
self.assertSequenceEqual(output.split('\n'), table_desc3.split('\n'))
def test_describe_columnfamilies_output(self):
output_re = r'''

View File

@ -28,7 +28,7 @@ INSERT INTO has_all_types (num, intcol, asciicol, bigintcol, blobcol, booleancol
decimalcol, doublecol, floatcol, smallintcol, textcol,
timestampcol, tinyintcol, uuidcol, varcharcol, varintcol)
VALUES (1, 2147483647, '__!''$#@!~"', 9223372036854775807, 0xffffffffffffffffff, true,
0.00000000000001, 9999999.999, 99999.99, 32767, '∭Ƕ⑮ฑ➳❏''',
0.00000000000001, 9999999.999, 99999.999, 32767, '∭Ƕ⑮ฑ➳❏''',
'1950-01-01+0000', 127, ffffffff-ffff-ffff-ffff-ffffffffffff, 'newline->
<-', 9);