mirror of https://github.com/apache/cassandra
remove unused imports in cqlsh.py and cqlshlib
patch by Brad Schoening; reviewed by Stefan Miklosovic and Brandon Williams for CASSANDRA-17413
This commit is contained in:
parent
ae50cbd1ad
commit
27ab63f005
|
|
@ -1,4 +1,5 @@
|
||||||
4.1
|
4.1
|
||||||
|
* remove unused imports in cqlsh.py and cqlshlib (CASSANDRA-17413)
|
||||||
* deprecate property windows_timer_interval (CASSANDRA-17404)
|
* deprecate property windows_timer_interval (CASSANDRA-17404)
|
||||||
* Expose streaming as a vtable (CASSANDRA-17390)
|
* Expose streaming as a vtable (CASSANDRA-17390)
|
||||||
* Make startup checks configurable (CASSANDRA-17220)
|
* Make startup checks configurable (CASSANDRA-17220)
|
||||||
|
|
|
||||||
13
bin/cqlsh.py
13
bin/cqlsh.py
|
|
@ -16,8 +16,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import division, unicode_literals, print_function
|
|
||||||
|
|
||||||
import cmd
|
import cmd
|
||||||
import codecs
|
import codecs
|
||||||
import csv
|
import csv
|
||||||
|
|
@ -37,7 +35,7 @@ from contextlib import contextmanager
|
||||||
from glob import glob
|
from glob import glob
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
if sys.version_info < (3, 6) and sys.version_info[0:2] != (2, 7):
|
if sys.version_info < (3, 6):
|
||||||
sys.exit("\ncqlsh requires Python 3.6+\n")
|
sys.exit("\ncqlsh requires Python 3.6+\n")
|
||||||
|
|
||||||
# see CASSANDRA-10428
|
# see CASSANDRA-10428
|
||||||
|
|
@ -140,8 +138,7 @@ from cassandra.auth import PlainTextAuthProvider
|
||||||
from cassandra.cluster import Cluster
|
from cassandra.cluster import Cluster
|
||||||
from cassandra.cqltypes import cql_typename
|
from cassandra.cqltypes import cql_typename
|
||||||
from cassandra.marshal import int64_unpack
|
from cassandra.marshal import int64_unpack
|
||||||
from cassandra.metadata import (ColumnMetadata, KeyspaceMetadata,
|
from cassandra.metadata import (ColumnMetadata, KeyspaceMetadata, TableMetadata)
|
||||||
TableMetadata, protect_name, protect_names)
|
|
||||||
from cassandra.policies import WhiteListRoundRobinPolicy
|
from cassandra.policies import WhiteListRoundRobinPolicy
|
||||||
from cassandra.query import SimpleStatement, ordered_dict_factory, TraceUnavailable
|
from cassandra.query import SimpleStatement, ordered_dict_factory, TraceUnavailable
|
||||||
from cassandra.util import datetime_from_timestamp
|
from cassandra.util import datetime_from_timestamp
|
||||||
|
|
@ -152,15 +149,15 @@ cqlshlibdir = os.path.join(CASSANDRA_PATH, 'pylib')
|
||||||
if os.path.isdir(cqlshlibdir):
|
if os.path.isdir(cqlshlibdir):
|
||||||
sys.path.insert(0, cqlshlibdir)
|
sys.path.insert(0, cqlshlibdir)
|
||||||
|
|
||||||
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, cqlshhandling
|
from cqlshlib import cql3handling, pylexotron, sslhandling, cqlshhandling
|
||||||
from cqlshlib.copyutil import ExportTask, ImportTask
|
from cqlshlib.copyutil import ExportTask, ImportTask
|
||||||
from cqlshlib.displaying import (ANSI_RESET, BLUE, COLUMN_NAME_COLORS, CYAN,
|
from cqlshlib.displaying import (ANSI_RESET, BLUE, COLUMN_NAME_COLORS, CYAN,
|
||||||
RED, WHITE, FormattedValue, colorme)
|
RED, WHITE, FormattedValue, colorme)
|
||||||
from cqlshlib.formatting import (DEFAULT_DATE_FORMAT, DEFAULT_NANOTIME_FORMAT,
|
from cqlshlib.formatting import (DEFAULT_DATE_FORMAT, DEFAULT_NANOTIME_FORMAT,
|
||||||
DEFAULT_TIMESTAMP_FORMAT, CqlType, DateTimeFormat,
|
DEFAULT_TIMESTAMP_FORMAT, CqlType, DateTimeFormat,
|
||||||
format_by_type, formatter_for)
|
format_by_type)
|
||||||
from cqlshlib.tracing import print_trace, print_trace_session
|
from cqlshlib.tracing import print_trace, print_trace_session
|
||||||
from cqlshlib.util import get_file_encoding_bomsize, trim_if_present
|
from cqlshlib.util import get_file_encoding_bomsize
|
||||||
|
|
||||||
DEFAULT_HOST = '127.0.0.1'
|
DEFAULT_HOST = '127.0.0.1'
|
||||||
DEFAULT_PORT = 9042
|
DEFAULT_PORT = 9042
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
import csv
|
import csv
|
||||||
import datetime
|
import datetime
|
||||||
import json
|
import json
|
||||||
|
|
@ -33,6 +32,7 @@ import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
import errno
|
||||||
|
|
||||||
from bisect import bisect_right
|
from bisect import bisect_right
|
||||||
from calendar import timegm
|
from calendar import timegm
|
||||||
|
|
@ -51,7 +51,7 @@ from six.moves.queue import Queue
|
||||||
|
|
||||||
from cassandra import OperationTimedOut
|
from cassandra import OperationTimedOut
|
||||||
from cassandra.cluster import Cluster, DefaultConnection
|
from cassandra.cluster import Cluster, DefaultConnection
|
||||||
from cassandra.cqltypes import ReversedType, UserType, BytesType, VarcharType
|
from cassandra.cqltypes import ReversedType, UserType, VarcharType
|
||||||
from cassandra.metadata import protect_name, protect_names, protect_value
|
from cassandra.metadata import protect_name, protect_names, protect_value
|
||||||
from cassandra.policies import RetryPolicy, WhiteListRoundRobinPolicy, DCAwareRoundRobinPolicy, FallthroughRetryPolicy
|
from cassandra.policies import RetryPolicy, WhiteListRoundRobinPolicy, DCAwareRoundRobinPolicy, FallthroughRetryPolicy
|
||||||
from cassandra.query import BatchStatement, BatchType, SimpleStatement, tuple_factory
|
from cassandra.query import BatchStatement, BatchType, SimpleStatement, tuple_factory
|
||||||
|
|
@ -201,6 +201,7 @@ class ReceivingChannels(object):
|
||||||
try:
|
try:
|
||||||
readable, _, _ = select(self._readers, [], [], timeout)
|
readable, _, _ = select(self._readers, [], [], timeout)
|
||||||
except select.error as exc:
|
except select.error as exc:
|
||||||
|
# TODO: PEP 475 in Python 3.5 should make this unnecessary
|
||||||
# Do not abort on window resize:
|
# Do not abort on window resize:
|
||||||
if exc[0] != errno.EINTR:
|
if exc[0] != errno.EINTR:
|
||||||
raise
|
raise
|
||||||
|
|
|
||||||
|
|
@ -111,12 +111,6 @@ class CqlParsingRuleSet(pylexotron.ParsingRuleSet):
|
||||||
# don't put any 'endline' tokens in output
|
# don't put any 'endline' tokens in output
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# Convert all unicode tokens to ascii, where possible. This
|
|
||||||
# helps avoid problems with performing unicode-incompatible
|
|
||||||
# operations on tokens (like .lower()). See CASSANDRA-9083
|
|
||||||
# for one example of this.
|
|
||||||
str_token = t[1]
|
|
||||||
|
|
||||||
curstmt.append(t)
|
curstmt.append(t)
|
||||||
if t[0] == 'endtoken':
|
if t[0] == 'endtoken':
|
||||||
term_on_nl = False
|
term_on_nl = False
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
RED = '\033[0;1;31m'
|
RED = '\033[0;1;31m'
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import binascii
|
import binascii
|
||||||
import calendar
|
import calendar
|
||||||
import datetime
|
import datetime
|
||||||
|
|
@ -23,7 +21,6 @@ import math
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import platform
|
|
||||||
|
|
||||||
from six import ensure_text
|
from six import ensure_text
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,3 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from .cassconnect import create_db, remove_db
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,6 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import six
|
import six
|
||||||
|
|
||||||
|
|
@ -65,6 +63,7 @@ for colordef in color_defs:
|
||||||
for c in nameset:
|
for c in nameset:
|
||||||
colors_by_name[c] = colorcode
|
colors_by_name[c] = colorcode
|
||||||
|
|
||||||
|
|
||||||
class ColoredChar(object):
|
class ColoredChar(object):
|
||||||
def __init__(self, c, colorcode):
|
def __init__(self, c, colorcode):
|
||||||
self.c = c
|
self.c = c
|
||||||
|
|
@ -104,6 +103,7 @@ class ColoredChar(object):
|
||||||
def colortag(self):
|
def colortag(self):
|
||||||
return lookup_letter_from_code(self._colorcode)
|
return lookup_letter_from_code(self._colorcode)
|
||||||
|
|
||||||
|
|
||||||
class ColoredText(object):
|
class ColoredText(object):
|
||||||
def __init__(self, source=''):
|
def __init__(self, source=''):
|
||||||
if isinstance(source, six.text_type):
|
if isinstance(source, six.text_type):
|
||||||
|
|
@ -152,7 +152,6 @@ class ColoredText(object):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def parse_sgr_param(curclr, paramstr):
|
def parse_sgr_param(curclr, paramstr):
|
||||||
oldclr = curclr
|
|
||||||
args = list(map(int, paramstr.split(';')))
|
args = list(map(int, paramstr.split(';')))
|
||||||
for a in args:
|
for a in args:
|
||||||
if a == 0:
|
if a == 0:
|
||||||
|
|
@ -179,15 +178,19 @@ class ColoredText(object):
|
||||||
def colortags(self):
|
def colortags(self):
|
||||||
return ''.join([c.colortag() for c in self.chars])
|
return ''.join([c.colortag() for c in self.chars])
|
||||||
|
|
||||||
|
|
||||||
def lookup_colorcode(name):
|
def lookup_colorcode(name):
|
||||||
return colors_by_name[name]
|
return colors_by_name[name]
|
||||||
|
|
||||||
|
|
||||||
def lookup_colorname(code):
|
def lookup_colorname(code):
|
||||||
return colors_by_num.get(code, 'Unknown-color-0%o' % code)
|
return colors_by_num.get(code, 'Unknown-color-0%o' % code)
|
||||||
|
|
||||||
|
|
||||||
def lookup_colorletter(letter):
|
def lookup_colorletter(letter):
|
||||||
return colors_by_letter[letter]
|
return colors_by_letter[letter]
|
||||||
|
|
||||||
|
|
||||||
def lookup_letter_from_code(code):
|
def lookup_letter_from_code(code):
|
||||||
letr = letters_by_num.get(code, ' ')
|
letr = letters_by_num.get(code, ' ')
|
||||||
if letr == 'n':
|
if letr == 'n':
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,8 @@ def cql_rule_set():
|
||||||
return CqlRuleSet
|
return CqlRuleSet
|
||||||
|
|
||||||
|
|
||||||
class DEFAULTVAL: pass
|
class DEFAULTVAL:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
__TEST__ = False
|
__TEST__ = False
|
||||||
|
|
|
||||||
|
|
@ -16,18 +16,15 @@
|
||||||
|
|
||||||
# NOTE: this testing tool is *nix specific
|
# NOTE: this testing tool is *nix specific
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import contextlib
|
import contextlib
|
||||||
import subprocess
|
import subprocess
|
||||||
import signal
|
import signal
|
||||||
import math
|
|
||||||
from time import time
|
from time import time
|
||||||
from . import basecase
|
from . import basecase
|
||||||
from os.path import join, normpath
|
from os.path import join
|
||||||
|
|
||||||
|
|
||||||
import pty
|
import pty
|
||||||
|
|
@ -42,6 +39,7 @@ except AttributeError:
|
||||||
# Python 3.7+
|
# Python 3.7+
|
||||||
Pattern = re.Pattern
|
Pattern = re.Pattern
|
||||||
|
|
||||||
|
|
||||||
def get_smm_sequence(term='xterm'):
|
def get_smm_sequence(term='xterm'):
|
||||||
"""
|
"""
|
||||||
Return the set meta mode (smm) sequence, if any.
|
Return the set meta mode (smm) sequence, if any.
|
||||||
|
|
@ -57,10 +55,12 @@ def get_smm_sequence(term='xterm'):
|
||||||
result = result.decode("utf-8")
|
result = result.decode("utf-8")
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_SMM_SEQUENCE = get_smm_sequence()
|
DEFAULT_SMM_SEQUENCE = get_smm_sequence()
|
||||||
|
|
||||||
cqlshlog = basecase.cqlshlog
|
cqlshlog = basecase.cqlshlog
|
||||||
|
|
||||||
|
|
||||||
def set_controlling_pty(master, slave):
|
def set_controlling_pty(master, slave):
|
||||||
os.setsid()
|
os.setsid()
|
||||||
os.close(master)
|
os.close(master)
|
||||||
|
|
@ -70,6 +70,7 @@ def set_controlling_pty(master, slave):
|
||||||
os.close(slave)
|
os.close(slave)
|
||||||
os.close(os.open(os.ttyname(1), os.O_RDWR))
|
os.close(os.open(os.ttyname(1), os.O_RDWR))
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def raising_signal(signum, exc):
|
def raising_signal(signum, exc):
|
||||||
"""
|
"""
|
||||||
|
|
@ -85,9 +86,11 @@ def raising_signal(signum, exc):
|
||||||
finally:
|
finally:
|
||||||
signal.signal(signum, oldhandlr)
|
signal.signal(signum, oldhandlr)
|
||||||
|
|
||||||
|
|
||||||
class TimeoutError(Exception):
|
class TimeoutError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
@contextlib.contextmanager
|
@contextlib.contextmanager
|
||||||
def timing_out(seconds):
|
def timing_out(seconds):
|
||||||
if seconds is None:
|
if seconds is None:
|
||||||
|
|
@ -107,6 +110,7 @@ def timing_out(seconds):
|
||||||
def noop(*a):
|
def noop(*a):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ProcRunner:
|
class ProcRunner:
|
||||||
def __init__(self, path, tty=True, env=None, args=()):
|
def __init__(self, path, tty=True, env=None, args=()):
|
||||||
self.exe_path = path
|
self.exe_path = path
|
||||||
|
|
@ -222,6 +226,7 @@ class ProcRunner:
|
||||||
curtime = time()
|
curtime = time()
|
||||||
return got
|
return got
|
||||||
|
|
||||||
|
|
||||||
class CqlshRunner(ProcRunner):
|
class CqlshRunner(ProcRunner):
|
||||||
def __init__(self, path=None, host=None, port=None, keyspace=None, cqlver=None,
|
def __init__(self, path=None, host=None, port=None, keyspace=None, cqlver=None,
|
||||||
args=(), prompt=DEFAULT_CQLSH_PROMPT, env=None, tty=True, **kwargs):
|
args=(), prompt=DEFAULT_CQLSH_PROMPT, env=None, tty=True, **kwargs):
|
||||||
|
|
@ -256,7 +261,7 @@ class CqlshRunner(ProcRunner):
|
||||||
self.output_header = self.read_to_next_prompt()
|
self.output_header = self.read_to_next_prompt()
|
||||||
|
|
||||||
def read_to_next_prompt(self, timeout=10.0):
|
def read_to_next_prompt(self, timeout=10.0):
|
||||||
return self.read_until(self.prompt, timeout=timeout, ptty_timeout=3, replace=[DEFAULT_SMM_SEQUENCE,])
|
return self.read_until(self.prompt, timeout=timeout, ptty_timeout=3, replace=[DEFAULT_SMM_SEQUENCE])
|
||||||
|
|
||||||
def read_up_to_timeout(self, timeout, blksize=4096):
|
def read_up_to_timeout(self, timeout, blksize=4096):
|
||||||
output = ProcRunner.read_up_to_timeout(self, timeout, blksize=blksize)
|
output = ProcRunner.read_up_to_timeout(self, timeout, blksize=blksize)
|
||||||
|
|
@ -281,12 +286,14 @@ class CqlshRunner(ProcRunner):
|
||||||
promptline = output
|
promptline = output
|
||||||
output = ''
|
output = ''
|
||||||
assert re.match(self.prompt, DEFAULT_PREFIX + promptline), \
|
assert re.match(self.prompt, DEFAULT_PREFIX + promptline), \
|
||||||
'last line of output %r does not match %r?' % (promptline, self.prompt)
|
'last line of output %r does not match %r?' % (promptline, self.prompt)
|
||||||
return output + '\n'
|
return output + '\n'
|
||||||
|
|
||||||
|
|
||||||
def run_cqlsh(**kwargs):
|
def run_cqlsh(**kwargs):
|
||||||
return contextlib.closing(CqlshRunner(**kwargs))
|
return contextlib.closing(CqlshRunner(**kwargs))
|
||||||
|
|
||||||
|
|
||||||
def call_cqlsh(**kwargs):
|
def call_cqlsh(**kwargs):
|
||||||
kwargs.setdefault('prompt', None)
|
kwargs.setdefault('prompt', None)
|
||||||
proginput = kwargs.pop('input', '')
|
proginput = kwargs.pop('input', '')
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from cassandra.metadata import MIN_LONG, Murmur3Token, TokenMap
|
from cassandra.metadata import MIN_LONG, Murmur3Token
|
||||||
from cassandra.policies import SimpleConvictionPolicy
|
from cassandra.policies import SimpleConvictionPolicy
|
||||||
from cassandra.pool import Host
|
from cassandra.pool import Host
|
||||||
from unittest.mock import Mock
|
from unittest.mock import Mock
|
||||||
|
|
@ -75,7 +75,7 @@ class TestExportTask(CopyTaskTest):
|
||||||
}
|
}
|
||||||
# merge override options with standard options
|
# merge override options with standard options
|
||||||
overridden_opts = dict(self.opts)
|
overridden_opts = dict(self.opts)
|
||||||
for k,v in opts.items():
|
for k, v in opts.items():
|
||||||
overridden_opts[k] = v
|
overridden_opts[k] = v
|
||||||
export_task = ExportTask(shell, self.ks, self.table, self.columns, self.fname, overridden_opts, self.protocol_version, self.config_file)
|
export_task = ExportTask(shell, self.ks, self.table, self.columns, self.fname, overridden_opts, self.protocol_version, self.config_file)
|
||||||
assert export_task.get_ranges() == expected_ranges
|
assert export_task.get_ranges() == expected_ranges
|
||||||
|
|
@ -93,19 +93,19 @@ class TestExportTask(CopyTaskTest):
|
||||||
self._test_get_ranges_murmur3_base({'begintoken': 1, 'endtoken': -1}, {})
|
self._test_get_ranges_murmur3_base({'begintoken': 1, 'endtoken': -1}, {})
|
||||||
|
|
||||||
# simple case of a single range
|
# simple case of a single range
|
||||||
expected_ranges = {(1,2): {'hosts': ('10.0.0.4', '10.0.0.1', '10.0.0.2'), 'attempts': 0, 'rows': 0, 'workerno': -1}}
|
expected_ranges = {(1, 2): {'hosts': ('10.0.0.4', '10.0.0.1', '10.0.0.2'), 'attempts': 0, 'rows': 0, 'workerno': -1}}
|
||||||
self._test_get_ranges_murmur3_base({'begintoken': 1, 'endtoken': 2}, expected_ranges)
|
self._test_get_ranges_murmur3_base({'begintoken': 1, 'endtoken': 2}, expected_ranges)
|
||||||
|
|
||||||
# simple case of two contiguous ranges
|
# simple case of two contiguous ranges
|
||||||
expected_ranges = {
|
expected_ranges = {
|
||||||
(-4611686018427387903,0): {'hosts': ('10.0.0.3', '10.0.0.4', '10.0.0.1'), 'attempts': 0, 'rows': 0, 'workerno': -1},
|
(-4611686018427387903, 0): {'hosts': ('10.0.0.3', '10.0.0.4', '10.0.0.1'), 'attempts': 0, 'rows': 0, 'workerno': -1},
|
||||||
(0,1): {'hosts': ('10.0.0.4', '10.0.0.1', '10.0.0.2'), 'attempts': 0, 'rows': 0, 'workerno': -1}
|
(0, 1): {'hosts': ('10.0.0.4', '10.0.0.1', '10.0.0.2'), 'attempts': 0, 'rows': 0, 'workerno': -1}
|
||||||
}
|
}
|
||||||
self._test_get_ranges_murmur3_base({'begintoken': -4611686018427387903, 'endtoken': 1}, expected_ranges)
|
self._test_get_ranges_murmur3_base({'begintoken': -4611686018427387903, 'endtoken': 1}, expected_ranges)
|
||||||
|
|
||||||
# specify a begintoken only (endtoken defaults to None)
|
# specify a begintoken only (endtoken defaults to None)
|
||||||
expected_ranges = {
|
expected_ranges = {
|
||||||
(4611686018427387905,None): {'hosts': ('10.0.0.1', '10.0.0.2', '10.0.0.3'), 'attempts': 0, 'rows': 0, 'workerno': -1}
|
(4611686018427387905, None): {'hosts': ('10.0.0.1', '10.0.0.2', '10.0.0.3'), 'attempts': 0, 'rows': 0, 'workerno': -1}
|
||||||
}
|
}
|
||||||
self._test_get_ranges_murmur3_base({'begintoken': 4611686018427387905}, expected_ranges)
|
self._test_get_ranges_murmur3_base({'begintoken': 4611686018427387905}, expected_ranges)
|
||||||
|
|
||||||
|
|
@ -114,4 +114,3 @@ class TestExportTask(CopyTaskTest):
|
||||||
(None, MIN_LONG + 1): {'hosts': ('10.0.0.2', '10.0.0.3', '10.0.0.4'), 'attempts': 0, 'rows': 0, 'workerno': -1}
|
(None, MIN_LONG + 1): {'hosts': ('10.0.0.2', '10.0.0.3', '10.0.0.4'), 'attempts': 0, 'rows': 0, 'workerno': -1}
|
||||||
}
|
}
|
||||||
self._test_get_ranges_murmur3_base({'endtoken': MIN_LONG + 1}, expected_ranges)
|
self._test_get_ranges_murmur3_base({'endtoken': MIN_LONG + 1}, expected_ranges)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -778,12 +778,12 @@ class TestCqlParsing(TestCase):
|
||||||
|
|
||||||
|
|
||||||
def parse_cqlsh_statements(text):
|
def parse_cqlsh_statements(text):
|
||||||
'''
|
"""
|
||||||
Runs its argument through the sequence of parsing steps that cqlsh takes its
|
Runs its argument through the sequence of parsing steps that cqlsh takes its
|
||||||
input through.
|
input through.
|
||||||
|
|
||||||
Currently does not handle batch statements.
|
Currently does not handle batch statements.
|
||||||
'''
|
"""
|
||||||
# based on onecmd
|
# based on onecmd
|
||||||
statements, _ = CqlRuleSet.cql_split_statements(text)
|
statements, _ = CqlRuleSet.cql_split_statements(text)
|
||||||
# stops here. For regular cql commands, onecmd just splits it and sends it
|
# stops here. For regular cql commands, onecmd just splits it and sends it
|
||||||
|
|
@ -799,13 +799,13 @@ def tokens_with_types(lexed):
|
||||||
|
|
||||||
|
|
||||||
def strip_final_empty_items(xs):
|
def strip_final_empty_items(xs):
|
||||||
'''
|
"""
|
||||||
Returns its a copy of argument as a list, but with any terminating
|
Returns its a copy of argument as a list, but with any terminating
|
||||||
subsequence of falsey values removed.
|
subsequence of falsey values removed.
|
||||||
|
|
||||||
>>> strip_final_empty_items([[3, 4], [5, 6, 7], [], [], [1], []])
|
>>> strip_final_empty_items([[3, 4], [5, 6, 7], [], [], [1], []])
|
||||||
[[3, 4], [5, 6, 7], [], [], [1]]
|
[[3, 4], [5, 6, 7], [], [], [1]]
|
||||||
'''
|
"""
|
||||||
rv = list(xs)
|
rv = list(xs)
|
||||||
|
|
||||||
while rv and not rv[-1]:
|
while rv and not rv[-1]:
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ COMPLETION_RESPONSE_TIME = 0.5
|
||||||
|
|
||||||
completion_separation_re = re.compile(r'\s+')
|
completion_separation_re = re.compile(r'\s+')
|
||||||
|
|
||||||
|
|
||||||
class CqlshCompletionCase(BaseTestCase):
|
class CqlshCompletionCase(BaseTestCase):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -52,7 +53,7 @@ class CqlshCompletionCase(BaseTestCase):
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
env['COLUMNS'] = '100000'
|
env['COLUMNS'] = '100000'
|
||||||
if (locale.getpreferredencoding() != 'UTF-8'):
|
if (locale.getpreferredencoding() != 'UTF-8'):
|
||||||
env['LC_CTYPE'] = 'en_US.utf8'
|
env['LC_CTYPE'] = 'en_US.utf8'
|
||||||
self.cqlsh_runner = testrun_cqlsh(cqlver=None, env=env)
|
self.cqlsh_runner = testrun_cqlsh(cqlver=None, env=env)
|
||||||
self.cqlsh = self.cqlsh_runner.__enter__()
|
self.cqlsh = self.cqlsh_runner.__enter__()
|
||||||
|
|
||||||
|
|
@ -150,7 +151,6 @@ class CqlshCompletionCase(BaseTestCase):
|
||||||
# retry once
|
# retry once
|
||||||
self.cqlsh.send(CTRL_C)
|
self.cqlsh.send(CTRL_C)
|
||||||
self.cqlsh.read_to_next_prompt(timeout=10.0)
|
self.cqlsh.read_to_next_prompt(timeout=10.0)
|
||||||
|
|
||||||
|
|
||||||
def strategies(self):
|
def strategies(self):
|
||||||
return CqlRuleSet.replication_strategies
|
return CqlRuleSet.replication_strategies
|
||||||
|
|
@ -680,7 +680,7 @@ class TestCqlshCompletion(CqlshCompletionCase):
|
||||||
'timestamp_resolution', 'min_threshold', 'class', 'max_threshold',
|
'timestamp_resolution', 'min_threshold', 'class', 'max_threshold',
|
||||||
'tombstone_compaction_interval', 'tombstone_threshold',
|
'tombstone_compaction_interval', 'tombstone_threshold',
|
||||||
'enabled', 'unchecked_tombstone_compaction',
|
'enabled', 'unchecked_tombstone_compaction',
|
||||||
'only_purge_repaired_tombstones','provide_overlapping_tombstones'])
|
'only_purge_repaired_tombstones', 'provide_overlapping_tombstones'])
|
||||||
|
|
||||||
def test_complete_in_create_columnfamily(self):
|
def test_complete_in_create_columnfamily(self):
|
||||||
self.trycompletions('CREATE C', choices=['COLUMNFAMILY', 'CUSTOM'])
|
self.trycompletions('CREATE C', choices=['COLUMNFAMILY', 'CUSTOM'])
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,6 @@
|
||||||
# to configure behavior, define $CQL_TEST_HOST to the destination address
|
# to configure behavior, define $CQL_TEST_HOST to the destination address
|
||||||
# and $CQL_TEST_PORT to the associated port.
|
# and $CQL_TEST_PORT to the associated port.
|
||||||
|
|
||||||
from __future__ import unicode_literals, with_statement
|
|
||||||
|
|
||||||
import locale
|
import locale
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,7 @@
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
from __future__ import unicode_literals, with_statement
|
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
|
||||||
|
|
||||||
from .basecase import BaseTestCase
|
from .basecase import BaseTestCase
|
||||||
from .cassconnect import (get_cassandra_connection, create_keyspace, testrun_cqlsh)
|
from .cassconnect import (get_cassandra_connection, create_keyspace, testrun_cqlsh)
|
||||||
|
|
@ -71,5 +68,5 @@ class TestCqlshUnicode(BaseTestCase):
|
||||||
output = c.cmd_and_response('CREATE TYPE "%s" ( "%s" int );' % (v1, v2))
|
output = c.cmd_and_response('CREATE TYPE "%s" ( "%s" int );' % (v1, v2))
|
||||||
output = c.cmd_and_response('DESC TYPES;')
|
output = c.cmd_and_response('DESC TYPES;')
|
||||||
self.assertIn(v1, output)
|
self.assertIn(v1, output)
|
||||||
output = c.cmd_and_response('DESC TYPE "%s";' %(v1,))
|
output = c.cmd_and_response('DESC TYPE "%s";' % (v1,))
|
||||||
self.assertIn(v2, output)
|
self.assertIn(v2, output)
|
||||||
|
|
|
||||||
|
|
@ -47,4 +47,4 @@ class WinPty(object):
|
||||||
count = count + 1
|
count = count + 1
|
||||||
except Empty:
|
except Empty:
|
||||||
pass
|
pass
|
||||||
return buf.getvalue()
|
return buf.getvalue()
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@ import time
|
||||||
|
|
||||||
from cassandra.query import QueryTrace, TraceUnavailable
|
from cassandra.query import QueryTrace, TraceUnavailable
|
||||||
from cqlshlib.displaying import MAGENTA
|
from cqlshlib.displaying import MAGENTA
|
||||||
from cqlshlib.formatting import CqlType
|
|
||||||
|
|
||||||
|
|
||||||
def print_trace_session(shell, session, session_id, partial_session=False):
|
def print_trace_session(shell, session, session_id, partial_session=False):
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue