Merge branch 'cassandra-3.0' into trunk

This commit is contained in:
Sylvain Lebresne 2015-12-11 11:51:49 +01:00
commit 105ccb3d20
4 changed files with 13 additions and 24 deletions

View File

@ -155,7 +155,7 @@ cqlshlibdir = os.path.join(CASSANDRA_PATH, 'pylib')
if os.path.isdir(cqlshlibdir):
sys.path.insert(0, cqlshlibdir)
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, copy
from cqlshlib import cql3handling, cqlhandling, copyutil, pylexotron, sslhandling
from cqlshlib.displaying import (ANSI_RESET, BLUE, COLUMN_NAME_COLORS, CYAN,
RED, FormattedValue, colorme)
from cqlshlib.formatting import (DEFAULT_DATE_FORMAT, DEFAULT_NANOTIME_FORMAT,
@ -1843,7 +1843,7 @@ class Shell(cmd.Cmd):
print "\n%d rows %s in %s." % (rows, verb, describe_interval(timeend - timestart))
def perform_csv_import(self, ks, cf, columns, fname, opts):
csv_options, dialect_options, unrecognized_options = copy.parse_options(self, opts)
csv_options, dialect_options, unrecognized_options = copyutil.parse_options(self, opts)
if unrecognized_options:
self.printerr('Unrecognized COPY FROM options: %s'
% ', '.join(unrecognized_options.keys()))
@ -1869,7 +1869,7 @@ class Shell(cmd.Cmd):
linesource.next()
reader = csv.reader(linesource, **dialect_options)
num_processes = copy.get_num_processes(cap=4)
num_processes = copyutil.get_num_processes(cap=4)
for i in range(num_processes):
parent_conn, child_conn = mp.Pipe()
@ -1879,7 +1879,7 @@ class Shell(cmd.Cmd):
for process in processes:
process.start()
meter = copy.RateMeter(10000)
meter = copyutil.RateMeter(10000)
for current_record, row in enumerate(reader, start=1):
# write to the child process
pipes[current_record % num_processes].send((current_record, row))
@ -1953,13 +1953,13 @@ class Shell(cmd.Cmd):
return True
def perform_csv_export(self, ks, cf, columns, fname, opts):
csv_options, dialect_options, unrecognized_options = copy.parse_options(self, opts)
csv_options, dialect_options, unrecognized_options = copyutil.parse_options(self, opts)
if unrecognized_options:
self.printerr('Unrecognized COPY TO options: %s' % ', '.join(unrecognized_options.keys()))
return 0
return copy.ExportTask(self, ks, cf, columns, fname, csv_options, dialect_options,
DEFAULT_PROTOCOL_VERSION, CONFIG_FILE).run()
return copyutil.ExportTask(self, ks, cf, columns, fname, csv_options, dialect_options,
DEFAULT_PROTOCOL_VERSION, CONFIG_FILE).run()
def do_show(self, parsed):
"""

View File

@ -19,7 +19,6 @@ import json
import multiprocessing as mp
import os
import Queue
import random
import sys
import time
import traceback

View File

@ -18,7 +18,7 @@ import os
import sys
import logging
from itertools import izip
from os.path import dirname, join, normpath, islink
from os.path import dirname, join, normpath
cqlshlog = logging.getLogger('test_cqlsh')
@ -31,21 +31,15 @@ except ImportError:
import unittest
rundir = dirname(__file__)
path_to_cqlsh = normpath(join(rundir, '..', '..', '..', 'bin', 'cqlsh.py'))
cqlshdir = normpath(join(rundir, '..', '..', '..', 'bin'))
path_to_cqlsh = normpath(join(cqlshdir, 'cqlsh.py'))
# symlink a ".py" file to cqlsh main script, so we can load it as a module
modulepath = join(rundir, 'cqlsh.py')
try:
if islink(modulepath):
os.unlink(modulepath)
except OSError:
pass
os.symlink(path_to_cqlsh, modulepath)
sys.path.append(cqlshdir)
sys.path.append(rundir)
import cqlsh
cql = cqlsh.cassandra.cluster.Cluster
policy = cqlsh.cassandra.policies.RoundRobinPolicy()
quote_name = cqlsh.cassandra.metadata.maybe_escape_name
TEST_HOST = os.environ.get('CQL_TEST_HOST', '127.0.0.1')
TEST_PORT = int(os.environ.get('CQL_TEST_PORT', 9042))

View File

@ -19,9 +19,8 @@ from __future__ import with_statement
import contextlib
import tempfile
import os.path
from .basecase import cql, cqlsh, cqlshlog, TEST_HOST, TEST_PORT, rundir, policy
from .basecase import cql, cqlsh, cqlshlog, TEST_HOST, TEST_PORT, rundir, policy, quote_name
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,9 +125,6 @@ def cassandra_cursor(cql_version=None, ks=''):
def cql_rule_set():
return cqlsh.cql3handling.CqlRuleSet
def quote_name(name):
return maybe_escape_name(name)
class DEFAULTVAL: pass
def testrun_cqlsh(keyspace=DEFAULTVAL, **kwargs):