コード例 #1
0
ファイル: tests.py プロジェクト: rlugojr/crate
def setUpTutorials(test):
    setUp(test)
    import_dir = '/tmp/best_practice_data'
    source_dir = 'sql/src/test/resources/essetup/data/best_practice'
    if not os.path.isdir(import_dir):
        os.mkdir(import_dir)
    shutil.copy(project_path(source_dir, 'data_import.json'),
                os.path.join(import_dir, "users.json"))
    shutil.copy(project_path(source_dir, 'data_import.json.gz'),
                os.path.join(import_dir, "users.json.gz"))
    shutil.copy(project_path(source_dir, 'data_import_1408312800.json'),
                os.path.join(import_dir, "users_1408312800.json"))
コード例 #2
0
ファイル: tests.py プロジェクト: rlugojr/crate
def setUpQuotes(test):
    test.globs['cmd'] = cmd
    cmd.stmt("""
        create table quotes (
          id integer primary key,
          quote string,
          index quote_ft using fulltext (quote)
        ) clustered by(id) into 2 shards with(number_of_replicas=0)""")

    import_dir = '/tmp/import_data'
    if not os.path.isdir(import_dir):
        os.mkdir(import_dir)
    shutil.copy(project_path('sql/src/test/resources/essetup/data/copy', 'test_copy_from.json'),
                os.path.join(import_dir, "quotes.json"))
コード例 #3
0
ファイル: tests.py プロジェクト: xuchanggen/crate
class CrateTestCmd(CrateCmd):
    def __init__(self, **kwargs):
        super(CrateTestCmd, self).__init__(**kwargs)
        doctest_print = PrintWrapper()
        self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n')

    def stmt(self, stmt):
        stmt = stmt.replace('\n', ' ')
        if stmt.startswith('\\'):
            self.process(stmt)
        else:
            self.execute(stmt)


cmd = CrateTestCmd(is_tty=False)
jars = [project_path('blackbox', 'tmp')]
jars += glob.glob(crate_path('lib', '*.jar'))
java_repl = JavaRepl(jars=jars, port=GLOBAL_PORT_POOL.get())


def wait_for_schema_update(schema, table, column):
    conn = connect('localhost:' + str(CRATE_HTTP_PORT))
    c = conn.cursor()
    count = 0
    while count == 0:
        c.execute(('select count(*) from information_schema.columns '
                   'where table_schema = ? and table_name = ? '
                   'and column_name = ?'), (schema, table, column))
        count = c.fetchone()[0]

コード例 #4
0
ファイル: tests.py プロジェクト: TonyWuLihu/crate
class CrateTestCmd(CrateCmd):

    def __init__(self, **kwargs):
        super(CrateTestCmd, self).__init__(**kwargs)
        doctest_print = PrintWrapper()
        self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n')

    def stmt(self, stmt):
        stmt = stmt.replace('\n', ' ')
        if stmt.startswith('\\'):
            self.process(stmt)
        else:
            self.execute(stmt)

cmd = CrateTestCmd(is_tty=False)
jars = [project_path('blackbox', 'tmp', 'crateClient', 'crate-client.jar')]
jars += glob.glob(crate_path('lib', '*.jar'))
java_repl = JavaRepl(
    jars=jars,
    port=GLOBAL_PORT_POOL.get()
)


def wait_for_schema_update(schema, table, column):
    conn = connect('localhost:' + str(CRATE_HTTP_PORT))
    c = conn.cursor()
    count = 0
    while count == 0:
        c.execute(('select count(*) from information_schema.columns '
                    'where schema_name = ? and table_name = ? '
                    'and column_name = ?'),
コード例 #5
0
ファイル: tests.py プロジェクト: joe2hpimn/crate
class CrateTestCmd(CrateCmd):
    def __init__(self, **kwargs):
        super(CrateTestCmd, self).__init__(**kwargs)
        doctest_print = PrintWrapper()
        self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n')

    def stmt(self, stmt):
        stmt = stmt.replace('\n', ' ')
        if stmt.startswith('\\'):
            self.process(stmt)
        else:
            self.execute(stmt)


cmd = CrateTestCmd(is_tty=False)
jars = [project_path('blackbox', 'tmp', 'crateClient', 'crate-client.jar')]
jars += glob.glob(crate_path('lib', '*.jar'))
java_repl = JavaRepl(jars=jars, port=GLOBAL_PORT_POOL.get())


def wait_for_schema_update(schema, table, column):
    conn = connect('localhost:' + str(CRATE_HTTP_PORT))
    c = conn.cursor()
    count = 0
    while count == 0:
        c.execute(('select count(*) from information_schema.columns '
                   'where schema_name = ? and table_name = ? '
                   'and column_name = ?'), (schema, table, column))
        count = c.fetchone()[0]